简体   繁体   中英

input field text css on reset

Please refer the fiddle 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.

modified from your fiddle!:

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

here is working fiddle: http://jsfiddle.net/surendraVsingh/a765q/13/

HTML

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

Jquery

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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