日日摸夜夜添夜夜添aa,亚洲一区二区在线视频,国产精品入口在线看麻豆,久久久久久久99精品免费观看

jquery獲取input中的值

程序猿 2021-03-10 21:50:23 2994瀏覽 加載中

如何用javascript獲取input輸入框中的值,js/jq通過name、id、class獲取input輸入框中的value

 <input type="text" name="one" id="two" class="three">

一、javascript獲取input輸入框中的值

通過 name

var text = document.getElementById("one").value

通過 id

var text = document.getElementById("two").value

通過 class

document.getElementsByClassName("three")[0].value

二、jquery獲取input輸入框中的值

通過 name

var text = $('input[name="one"]').val();

通過 id

var text = $('#two').val();

通過 class

var text = $('.three').val();


標簽:
最后修改:2025-04-26 00:17:25

非特殊說明,本博所有文章均為博主原創。