1.用jquery
$("input[name='btnAdd']").attr("value")
獲取value屬性值,其它屬性換attr的參數就OK
2.通過點來獲取:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form id="form1" name="form1">
<input name="n1" type="text" />
<input name="n3" type="text" />
<input name="n4" type="text" />
</form>
<script>
window.onload = function(){
var inputs = document.form1.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++) {
inputs[i].onclick = function(){
alert(this.name);
};
}
};
</script>
</body>
</html>
以上就是小編為大家帶來的獲取input標簽的所有屬性的方法全部內容了,希望大家多多支持~