简体   繁体   中英

Get values of textboxes created dynamically

I have a list of textboxes created dynamically accroding to the 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 );
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM