javascript如何让密码框显示默认值
答案:6 悬赏:0 手机版
解决时间 2021-02-05 20:44
- 提问者网友:骨子里的高雅
- 2021-02-05 16:13
javascript如何让密码框显示默认值
最佳答案
- 五星知识达人网友:骨子里都是戏
- 2021-02-05 17:36
与设置文本框默认值的方法一样,设置密码框的value属性。
1
2
3
4
5
6
7
8
9
//普通设置dao
document.getElementById("pass_ipt").value="123456";
//jquery
$("#pass_ipt").val("123456");
//要显示密码框的内容,可版以权将密码框改为普通文本框
document.getElementById("pass_ipt").type="text";
1
2
3
4
5
6
7
8
9
//普通设置dao
document.getElementById("pass_ipt").value="123456";
//jquery
$("#pass_ipt").val("123456");
//要显示密码框的内容,可版以权将密码框改为普通文本框
document.getElementById("pass_ipt").type="text";
全部回答
- 1楼网友:胯下狙击手
- 2021-02-05 22:11
应该有value属性吧 给value属性赋值就可以了吧
- 2楼网友:话散在刀尖上
- 2021-02-05 20:50
打酱油的
- 3楼网友:不如潦草
- 2021-02-05 20:14
直接给密码框赋值就可以了,value=值就可以了,没你想的那么麻烦,根本不用js实现,直接从后台取出密码,前台显示,跟正常的text一样
- 4楼网友:十鸦
- 2021-02-05 18:43
..如今是刷海龙钱是最多的大年夜约一次100多j然后在打出几件海龙的设备..就能赚听多了..并且机械大年夜师没啥请求呼唤完器械就站着就行了
- 5楼网友:蓝房子
- 2021-02-05 18:31
这样应该可以吧。应用到jquery
测试页面:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="text" value="请输入用户名" id="username" style="width:150px;height:24px;"/>
<div id="pwd_warpper" style="width:150px;height:24px;">
<input type="text" value="请输入密码" id="_password" onfocus="showpassword();" style="width:150px;height:24px;"/>
</div>
<script type="text/javascript" src="jquery.js"></script> //你自己的jquery.js的文件名,需要导入
<script type="text/javascript" src="code.js"></script>
code.js
function showtext() {
if($("#password").val()=="") {
$("#pwd_warpper").html("<input type=\"text\" value=\"请输入密码\" id=\"_password\" onfocus=\"showpassword();\" style=\"width:150px;height:24px;\"/>");
}
}
function showpassword() {
$("#pwd_warpper").html("<input type=\"password\" value=\"\" id=\"password\" onblur=\"showtext();\" style=\"width:150px;height:24px;\"/>");
setTimeout(function(){
$("#password").focus();
},20);
}
$(function(){
var usernameDefStr = $("#username").val();
$("#username").focus(function(){
if($(this).val()==usernameDefStr)
$(this).val("");
});
$("#username").blur(function(){
if($(this).val()=="")
$(this).val(usernameDefStr);
});
});
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯