26/01/2011
Set default value into text box, such us search text box
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
<script>
$(document).ready(function() {
$("#search")
.val("Search...")
.css("color", "#ccc")
.focus(function(){
$(this).css("color", "black");
if ($(this).val() == "Search...")
{
$(this).val("");
}
})
.blur(function(){
$(this).css("color", "#ccc");
if ($(this).val() == "")
{
$(this).val("Search...");
}
});
});
</script>
<input type="text" id="search">
</body>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment