下面是修改,以便代碼您可以訪問已移除的標籤..
在click
處理
if (e.target.tagName == 'A') {
// Removes a tag when the little 'x' is clicked.
// Event is binded to the UL, otherwise a new tag (LI > A) wouldn't have this event attached to it.
var tag = $(e.target).parent();
//console.log(tag.children('input').val()); // this line extracts the tag value
tag.remove();
}
(的X)和keypress
處理器使用
if (tag_input.val() == "") {
// When backspace is pressed, the last tag is deleted.
var tag = $(el).children(".tagit-choice:last");
// console.log(tag.children('input').val()); // this line extracts the tag value
tag.remove();
}
演示在http://jsfiddle.net/gaby/yYHTu/1/
完美!謝謝 –