Jak możemy uzyskać identyfikator wybranych tagów za pomocą tagu Jquery?
Mam pole znacznika wejściowego i chcę uzyskać identyfikator wybranych tages Więc spróbowałemhttp://jsfiddle.net/u8zj5/19/ Ale moim problemem chcę, aby identyfikator nie był etykietą ani wartością, którą należy przekazaćid="show"
ale zawiodłem.
<input type="text" id="field1" name="field1" value=""/>
<span id="show">show ID here</span>
jQuery(document).ready(function(){
var availableTags = [{"id":"144","label":"Allicelabel","value":"Allice value"}];
jQuery("input#field1").each(function(){
var target = jQuery(this);
var currenttags = target.val();
target.hide()
.after("<ul class=\"tags\"><li>"+currenttags+"</li></ul>");
var instance = target.next();
instance.tagit({
tagSource:availableTags,
tagsChanged:function () {
var tags = instance.tagit('tags');
var tagString = [];
for (var i in tags){
tagString.push(tags[i].value);
}
$("#show").html(tagString.join(','));
},
sortable:true,
triggerKeys: ['enter', 'comma', 'tab']
});
});
});
Ktoś tutaj użyłjQuery Tagit (strona demonstracyjna) Pomoże mi to rozwiązać