我使用jQuery動態生成錨標籤。我已經添加了一個onclick屬性,但是當我點擊鏈接時,onclick不會觸發。爲什麼用JQuery生成的定位標記不會觸發onclick事件?
我生成的鏈接如下:
$(document).ready(function() {
var attributes = {
"id": "xxx",
"onclick": "alert('xxxx');",
"href": "https://localhost/widget/TabTest.aspx#"
};
var link = $.create("a", attributes);
$(link).append("xxxx");
$("#WidgetContainer").append(link);
});
值得注意的是$ .create不是jQuery本身的一部分。我以爲我只是不熟悉它。 – 2009-03-04 18:19:42