通过 JS 更改 html 输入类型? [英] change html input type by JS?

查看:21
本文介绍了通过 JS 更改 html 输入类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过标签本身做到这一点将类型从文本更改为密码

How to do this through the tag itself change type from text to password

<input type='text' name='pass'  />

是否可以在 input 标签本身中插入 JS 以将 type='text' 更改为 type='password'?

Is it possible to insert JS inside the input tag itself to change type='text' to type='password'?

推荐答案

尝试:

<input id="hybrid" type="text" name="password" />

<script type="text/javascript">
    document.getElementById('hybrid').type = 'password';
</script>

这篇关于通过 JS 更改 html 输入类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆