国产精品黄页网在线观看,欧美日韩国产综合新一区,国产欧美高清精品一区2,久久国产乱子伦免电影

jquery獲取input中的值

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

如何用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();


標(biāo)簽:
最后修改:2025-10-30 09:15:52

非特殊說明,本博所有文章均為博主原創(chuàng)。