怎样用JS实现点击文本框变密码框?
答案:3 悬赏:30
解决时间 2021-01-24 16:03
- 提问者网友:富士山上尢
- 2021-01-24 04:19
怎样用JS实现点击文本框变密码框?
最佳答案
- 二级知识专家网友:山有枢
- 2021-01-24 04:32
文本框和密码框都是input元素,只是type属性值不一样,因此只要将type属性由text修改为password即可实现文本框变密码框。示例如下:
1、HTML结构
2、javascript代码
function fun(obj){
obj.value = "";
obj.type = "password";
}3、效果演示
1、HTML结构
2、javascript代码
function fun(obj){
obj.value = "";
obj.type = "password";
}3、效果演示
全部回答
- 1楼网友:神鬼未生
- 2021-01-24 06:58
改变iuput的 type="password"
- 2楼网友:行雁书
- 2021-01-24 05:32
<script>
function changeAttr($this){
$this.setAttribute("type", "password");
}
</script>
<input type="text" onfocus="changeAttr(this)"/>
function changeAttr($this){
$this.setAttribute("type", "password");
}
</script>
<input type="text" onfocus="changeAttr(this)"/>
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯