Показать сообщение отдельно
  #3 (permalink)  
Старый 19.09.2013, 23:46
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

Сообщение от bastar
плагин что-то на подобии Placeholder
в качестве селектора любой предок ... если инпут заполнили Placeholder не показывается ...
<!DOCTYPE HTML>
<html>
	<head>
        <meta charset="utf-8">
        <style type="text/css">
        form#plh_form div{margin:5px 20px 5px 20px;position:relative}
        form#plh_form div label{position:absolute;top:3px;left:6px;color:#999}
        form#plh_form div input{margin-right:10px;width:150px}
        </style>
		<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
		<script>
        (function( $ ){
  $.fn.plh = function () {
    return this.each(function () {
        $("label", $(this))
            .each(function (d, c) {
                var b = $(c),
                    a = "#" + b.attr("for"),
                    a = $(a);
                a.focusin(function () {
                    b.hide()
                });
                a.focusout(function () {
                   !a.val() && b.show()
                })
            })
    })
};
})( jQuery );
</script>

		<script type = "text/javascript">
			$(document).ready(function(){
				$('body').plh()
			});
		</script>

	</head>
	<body>
		<form action="" id = "plh_form">
			<div>
				<label for="name">Name</label>
				<input type="text" id="name">
			</div>
			<div>
				<label for="surname">Surname</label>
				<input type="text" id="surname">
			</div>
			<div>
				<label for="password">Password</label>
				<input type="password" id="password">
			</div>
			<div>
				<label for="city">City</label>
				<input type="text" id="city">
			</div>
		</form>
	</body>
</html>
Ответить с цитированием