改变html输入类型由JS? [英] change html input type by JS?

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

问题描述

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

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

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

解决方案

尝试:

 < input id =hybridtype =textname =password/> 

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


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

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

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

解决方案

Try:

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

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

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

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