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