1
請參閱Jquery的單擊事件以下不再開往新創建的標籤
我使用。對,但它似乎click事件並不適用於新建項目。 新項目如何還能聽點擊事件?
$("#addNewAddresses").on("click", function() {
console.log("adding an address");
var $table = $(this).parent().find("table");
var html = "<tr class='item'>";
html += "<td class='city'>";
html += "<input id='City' class='inputStylized' type='text' placeholder='City'>";
html += "</td>";
html += " </tr>"
$(html).appendTo($table);
});
$(".city").on("click", function() {
console.log("city was clicked");
});