好吧,我有一個編輯按鈕,當我按下它,它改變爲「完成」按鈕。jQuery的不能識別類變化
這一切都通過jQuery的完成。
$(".icon-pencil").click(function() {
var pencil = $(this);
var row = $(this).parent('td').parent('tr');
row.find('td').not(":nth-last-child(2)").not(":last-child").each(function() {
$(this).html("hi");
});
pencil.attr('class', 'icon-ok-sign');
});
// save item
$(".icon-ok-sign").click(function() {
alert("hey");
});
當我按下一個「編輯」(「.icon-pencil
」)按鈕,它的類更改爲.icon-ok-sign
(我可以在Chrome控制檯中看到),
但是當我點擊它,顯示沒有警告。
當我創建它<span class="icon-ok-sign">press</span>
和壓機,警報顯示。
如何解決?
不知道這個作品!這是答案。 – schlingel
現在它調用兩次。 。 – Billie
我們需要更多信息來確定爲什麼要調用兩次。 – Stian