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"&g开发者_JAVA技巧t;
I'd like this : aa,bb
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... :)
精彩评论