1

为什么这不起作用?

<div id="download">
        <button>Download</button>
</div>

$("#download").find( ":button" ).click(function () {
    alert("io");
});

我尝试向按钮元素添加一个类和一个 Id。我也试过

<button>Download</button>

$(':button').click(function(){
    alert("io");
}
4

1 回答 1

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");
    });
});
于 2013-10-15T18:13:56.463 回答