[英]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... 使用jQuery ...
Onfocus - if #u has val "Username..." then change it to "" (blank) Onfocus-如果#u具有val“用户名...”,则将其更改为“”(空白)
OnBlur - if #u has val "" (blank) then change it back to "Username..." OnBlur-如果#u具有val“”(空白),则将其更改回“ Username ...”
Onfocus - if #p has val "Password..." then change it to "" (blank) ; Onfocus-如果#p具有val“ Password ...”,则将其更改为“”(空白); additionally here the val of attribute type should be changed to "password" from "text"... 另外,此处的属性类型的值应从“文本”更改为“密码” ...
OnBlur - if #u has val "" (blank) then change it back to "Password..." ; OnBlur-如果#u具有val“”(空白),则将其改回“ Password ...”; Again the val of type attribute should be changed back to "text" from "password"... 同样,应将type属性的val从“密码”更改回“文本” ...
$('#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. 但是,您要尝试执行的功能看起来很像占位符插件 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.