jquery获取input输入框中值的几种方法jquery

/ / 2025-06-11   阅读:2560
jquery获取input输入框中值的几种方法...

用jquery获取input输入框的值有多种方法,可以通过id、name、type等属性指定获取。


比如想要获取下面input的输入值,通常有以下方法:

<input id="test" name="test" type="text"/>
<script>
$(" #test ").val()  //通过id
$(" input[ name='test' ] ").val()  //通过name
$(" input[ type='text' ] ").val()  //通过type
$(" input[ type='text' ]").attr("value")
</script>


上一篇:jQuery tab选项卡切换

下一篇:没有了

我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈