为什么这不起作用?
<div id="download">
<button>Download</button>
</div>
$("#download").find( ":button" ).click(function () {
alert("io");
});
我尝试在按钮元素中添加一个类和一个Id。我也试过
<button>Download</button>
$(':button').click(function(){
alert("io");
}
答案 0 :(得分:2)
:button
仅匹配<input type="button"...
所以试试:
$(function(){ //And i would wrap it in DOM ready wrapper if the script is loaded earlier than the element in DOM.
$("#download").find("button").click(function () {
alert("io");
});
});