首页 > 解决方案 > Get values from custom tag of a textbox(autocomplete) and push into an array

问题描述

I have a one text-box(autocomplete) on page with id main_text,whose value changes dynamically.

    '<'my_custom_tag'>'name1|name2|address|country|provison'<'/my_custom_tag'>'

In above tag please do not consider any single quote, for display purpose i have mentioned it over here,other wise it was only displaying name1|name2|address|country|provison.

I want to get all the value between tags and push it into an array. I have tried using .result method of jquery but it was showing an error stating $(...).result not found

   $("#main_text").result(function(event,data,formatted){}

Any alternative approach to achieve the same, we need to .split the value from | so i can get individual values ,after that i will set those values into another text-box.

   $("my_name1").val(my_array[0]);
   $("my_name2").val(my_array[1]);
   $("my_address").val(my_array[2]);
   $("my_country").val(my_array[3]);
   $("my_provison").val(my_array[4]);

Also, if you check this link jqueryui.com/autocomplete it states .autocomplete is not a function in DOM

标签: javascriptjquery

解决方案


values = $("my_custom_tag").text().split("|");

推荐阅读