JS/jQuery获取input的值和清空input的value值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39702981/article/details/88798730

一、获取input的值
1、通过普通选择器获取
  通过类选择器获取:$('.class').val()
  通过id选择器获取:$(" #id").val()
2、通过标签选择器获取
  $(" input[ name='name' ] ").val()
  $(" input[ type='text' ] ").val()
  $(" input[ type='text' ]").attr("value")

二、清空input的value值
$(" #id").val("");
  $(" input[ name='name' ] ").val("")
  $(" input[ type='text' ] ").val("")
--------------------- 
作者:苦的人生遇见甜 
来源:CSDN 
原文:https://blog.csdn.net/wd2011063437/article/details/81237404 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/qq_39702981/article/details/88798730