我正在使用jQuery UI的拖放功能,並在'放下'它將項目添加到<ul>
元素與','後每個項目。對於最後需要的<li>
我該如何動態刪除逗號並在該項之前添加單詞and
?如何動態刪除逗號並添加單詞並使用jQuery
我想:
$(#pot ul li:last-child).text().replace(/,/g, '');
但是,這給了我沒有運氣。
$(function() {
$(".flavours li").draggable({
revert:true
});
$("#pot ul").droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
drop: function(event, ui, flavours) {
$("<li></li>").text(ui.draggable.text() + ',').appendTo(this);
}
})
});
優秀的答案,@dystroy你簡直令人驚歎。 – Adil 2013-03-11 17:45:52
@Adil感謝您的誇獎。來自像你這樣的經驗豐富的用戶,非常感謝。 – 2013-03-11 17:47:23