简单jQuery覆盖标签替代方案
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单jQuery覆盖标签替代方案相关的知识,希望对你有一定的参考价值。
Focus and keypress events determine when to hide, show, or dim a label.Use in tandem with the following html/CSS:
HTML
----
<li>
First Name
</li>
CSS
----
li {
position: relative;
}
label {
position: absolute;
top: 1px;
left: 1px;
cursor: text;
}
$(document).ready(function() { $('input[type=text]').focusin(function () { $(this).prev('label').css('color','#999'); }); $('input[type=text]').focusout(function () { $(this).prev('label').css('color','#111'); }); $('input[type=text]').keydown(function () { if($(this).attr('value') == '') { $(this).prev('label').hide(); } }); $('input[type=text]').keyup(function () { if ($(this).attr('value') == '') { $(this).prev('label').show(); $(this).prev('label').css('color','#999'); } }); });
以上是关于简单jQuery覆盖标签替代方案的主要内容,如果未能解决你的问题,请参考以下文章