Tuesday, 28 February 2012

input text box watermark effect using jquery


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js" type="text/javascript"></script>
<style type="text/css">
.UsernameCss { color:#9B9B9B; }
</style>

$("txtUserName").addClass("UsernameCss").val("Username")
.focus(function(){ if($(this).val() == "Username") { $(this).removeClass("UsernameCss").val(""); } })
.blur(function(){ if($(this).val() == "") { $(this).val("Search").addClass("UsernameCss"); } });

<input id="txtUserName" name="txtUserName" type="text" />


Tag: css, input, jquery, jquery watermark for textbox, textbox, watermark

No comments:

Post a Comment

Parsing JSON w/ @ symbol in it

To read the json response like bellow @ concatenated with attribute                             '{ "@id": 1001, "@name&q...