简体   繁体   English

重置时输入字段文本css

[英]input field text css on reset

Please refer the fiddle http://jsfiddle.net/a765q/1/ . 请参阅小提琴http://jsfiddle.net/a765q/1/

If I click the reset button, the text color turns to grey. 如果单击“重置”按钮,则文本颜色变为灰色。 How to do? 怎么做?

I would suggest using the newer placeholder attribute for this rather than the aproach you're going for. 我建议为此使用较新的placeholder属性,而不要使用您要使用的方法。

modified from your fiddle!: 从您的小提琴修改!:

<input name="address" id="address" type="text" placeholder="Address" />

here is working fiddle: http://jsfiddle.net/surendraVsingh/a765q/13/ 这是工作提琴: http : //jsfiddle.net/surendraVsingh/a765q/13/

HTML HTML

<form action="">
    <input name="address" id="address" type="text" value="Address" />
    <input name="reset" type="reset" value="Reset Form">
</form>​

Jquery jQuery的

 $('#address').focus(function(){
    $(this).val(''); 
    $(this).css('color', '#000'); 

});
$('input[type="reset"]').click(function(){

       $('#address').css('color', '#999'); 
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM