【问题标题】:jQuery tag-it, how to execute post when item removedjQuery tag-it,删除项目时如何执行发布
【发布时间】:2011-12-04 22:19:07
【问题描述】:
【问题讨论】:
标签:
javascript
jquery
tags
tag-it
【解决方案1】:
这是修改后的代码,因此您可以访问被删除的标签..
在click 处理程序中(x)
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();
}
并在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/