Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. $('#keywords').tagsInput({
  2. 'height':'auto',
  3. 'width':'350px',
  4. 'defaultText':'',
  5. 'delimiter': '|'
  6. });
  7. /*The delimiter option above overrides the default comma delimiter in the plugin allowing commas in tags if you prefer that...*/
  8.  
  9. var $keywords = $("#keywords").siblings(".tagsinput").children(".tag");
  10. var tags = [];
  11. for (var i = $keywords.length; i--;) {
  12. tags.push($($keywords[i]).text().substring(0, $($keywords[i]).text().length - 1).trim());
  13. }
  14.  
  15. /*Then if you only want the unique tags entered:*/
  16. var uniqueTags = $.unique(tags);
  17. alert(uniqueTags.toSource());
  18.  
  19. $("#btn").click(function () {
  20. var $tagWord = $("#tags_2").siblings(".tagsinput").children(".tag");
  21. var tags = [];
  22. for (var i = $tagWord.length; i--; ) {
  23. tags.push($($tagWord[i]).text().substring(0, $($tagWord[i]).text().length - 1).trim());
  24. }
  25.  
  26. /*Then if you only want the unique tags entered:*/
  27. var uqTags = $.unique(tags);
  28. alert(uqTags.toSource());
  29.  
  30. });
  31.  
  32. $.map($('.tag span'),function(e,i){return $(e).text().trim();})
  33.  
  34. <input type="text" name="to_addresses" class="to_addresses" data-role="tagsinput" >
  35.  
  36. $emails = []
  37. $.map($(".tagsinput span span"),function(e,i){
  38. $emails.push($(e).text().trim());
  39. })
  40.  
  41. function getKeywords() {
  42. return $.map($('.tag span'),function(e,i){
  43. return $(e).text().trim();
  44. });
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement