Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get values of jQuery Tags Input plugin

I use this jQuery Tags Input plugin:

jQuery Tags Input

but I can't get the values on my php file.

like image 378
KheirEddine Avatar asked Dec 16 '22 20:12

KheirEddine


1 Answers

If you are trying to get the individual values using jQuery you can use: (This is assuming the text input you made into a tag input has an id of "keywords")

$('#keywords').tagsInput({  
    'height':'auto',  
    'width':'350px',
    'defaultText':'',
    'delimiter': '|'
});
/*The delimiter option above overrides the default comma delimiter in the plugin allowing commas in tags if you prefer that...*/

var $keywords = $("#keywords").siblings(".tagsinput").children(".tag");  
var tags = [];  
for (var i = $keywords.length; i--;) {  
    tags.push($($keywords[i]).text().substring(0, $($keywords[i]).text().length -  1).trim());  
}  

/*Then if you only want the unique tags entered:*/  
var uniqueTags = $.unique(tags);  
alert(uniqueTags.toSource());
like image 92
Austin Floyd Avatar answered Jun 05 '23 23:06

Austin Floyd