<scripttype=”text/javascript”src=”jquery-1.4.4.min.js”></script>
<scripttype=”text/javascript”>
$(function(){
$(‘#test1’).click(function(){
alert($(‘#customBtn’).attr(‘value’));
});
$(‘#test2’).click(function(){
alert($(‘#customBtn’).val());
});
});
</script>
</head>
<body>
<buttonid=”customBtn”value=”test”>按钮</button>
<inputtype=”button”id=”test1″value=”getattr”/>
<inputtype=”button”id=”test2″value=”getval”/>
</body>
</html>
2、无意中把<button>标签放到了<form>标签中,你会发现点击这个button变成了提交,相当于<inputtype="submit"/>
这一点参见上面第二句标红的话就明白什么意思了。
不要把<button>标签当成<form>中的input元素。
验证这一点可以在测试下面的代码
<html>
<body>
<formaction=””>
<button>button</button>
<inputtype=”submit”value=”inputsubmit”/>
<inputtype=”button”value=”inputbutton”/>
</form>
</body>
</html>









