Change Input val. and type using jQuery
<input name="myusername" type="text" id="u" class="blackle u" value="Username..." />
<input name="mypassword" type="text" id="p" class="blackle p" value="Password..." />
Using jQuery...
Onfocus - if #u has val "Username..." then change it to "" (blank) OnBlur - if #u has val "" (blank) then change it back to "Username..."Onfocus - if #p has val "Password..." then change it to "" (blank) ; additionally here the val of attribute type should be changed to "password" from "text"...
O开发者_开发知识库nBlur - if #u has val "" (blank) then change it back to "Password..." ; Again the val of type attribute should be changed back to "text" from "password"...$('#u').focus(function() {
if($(this).val() === "Username...") {
$(this).val("");
}
}).blur(function() {
if($(this).val() === "") {
$(this).val("Username...");
}
});
Rinse and repeat. The functionality of what you're trying to do looks a lot like the placeholder plugin, though.
精彩评论