Get values of textboxes created dynamically
I have a list of textboxes created dynamically accroding to th开发者_运维技巧e user selection on aspx page.
I want to get and store into an array the value of these using Jquery, javascript.
how can i do that?
is it possible to loop through all the textboxes in a page?
Thanks
You can use map
to succinctly grab all the values:
var values = $("input[type=text]").map(function() {
return this.value; // or $(this).val()
}).get();
Loop over all textboxes using each
:
var values = [];
$("input[type=text]").each(function() {
values.push(this.value);
});
var values = new Array();
$(":text").each(function(){
values.push ( this.value );
});
精彩评论