我使用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