jQuery :text选择器

:text选择器语法

$(“:text”)

:text选择器语法解析

jQuery中的:text选择器可以匹配所有type属性值为text的input元素。

:text选择器实例代码

下面实例中,设计了两个input元素,type属性值分别为text和password,然后通过:text选择器进行选择,如果当前HTML页面中的其它地方的input也被选择了,样式也被修改了,只需要刷新当前页面即可:

<input type="text"><br>
<input type="password"><br>
<button id="test">确定</button>

<script>
$("#test").click(function(){
  $(":text").css("width","50%")
})
</script>

免责声明:内容仅供参考,不保证正确性!


全栈前端 / jQuery教程 :






Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.