如何在html中 将一部份内容默认为隐藏 在相应位置输入密码后可见

如何在html中 将一部份内容默认为隐藏 在相应位置输入密码后可见,第1张

这个简单:直接看代码

<input type="password" value="" onblur="aa(this.value)"/><span id="span" style="display:none"><font color="red">你的密码位数需要5-8位</font></span>

js:

function aa(value){

if(value.length<5||value.length>8){

document.getElementById("span").style.display="block"

}

}

1.可以使用 hide() 和 show() 方法来隐藏和显示 HTML 元素:

$("#hide").click(function(){

$("p").hide()

})

$("#show").click(function(){

$("p").show()

})

2.使用 toggle() 方法来切换 hide() 和 show() 方法。

显示被隐藏的元素,并隐藏已显示的元素:

$("button").click(function(){

$("p").toggle()

})

input 的type属性改为password

例子:<input type="password" name="textfield" id="textfield" />


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6116711.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存