Reputation: 19903
I'd like get a string with the value from some Textbox (with a specific class) and the values should be separate by a comma.
Any idea ?
Thanks,
Update1 :
I have this
<input type="text" id="A" class="test" value="aa">
<input type="text" id="B" class="test" value="bb">
I'd like this : aa,bb
Upvotes: 0
Views: 1301
Reputation: 65264
get the value then use split.
var str = 's,s,e,a,t,f';
var str2 = str.split(",");
alert(str2[2]); // alerts e
you can do var str = $('#someTextbox').val()
then proceed as above.
that is if I understood you clearly.
In your update, you can do it this way,
var str = $('.test').map(function(){
return this.value;
}).get().join(',');
str
now holds all the values found separated by comma, here's a demo cause I'm not good at explaining... :)
Upvotes: 5