Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read li values and insert them in an array?

Tags:

jquery

I have a ul with id ul1. In the UL I have 3 li, each containing a textbox. How do I read each and every li of the ul to retrieve the values of the textbox in the li and put them in an array?

like image 625
user269431 Avatar asked Jul 02 '26 11:07

user269431


1 Answers

It's as simple as this:

var values = [];

$('#ul1 li textarea').each(function() {
    values.push($(this).val());
});
like image 162
Tatu Ulmanen Avatar answered Jul 05 '26 04:07

Tatu Ulmanen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!