开发者

Get values of textboxes created dynamically

开发者 https://www.devze.com 2022-12-21 22:31 出处:网络
I have a list of textboxes created dynamically accroding to th开发者_运维技巧e user selection on aspx page.

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 );
});
0

精彩评论

暂无评论...
验证码 换一张
取 消