Avatar of Moti Mashiah
Moti Mashiah
Flag for Canada asked on

asp.net mvc

Hi Guys,
I have scenario when I have ul and inside the ul I insert dynamic li with jquery.

Please look at the code:
var rows = $("#addnew_product").append("<li style='font-size:16px'>" + txt + "</li>");

Open in new window

I limited users to insert 4 li in total and after the finish to insert the li I want to grab the text for each li the insert and for this I did something like that.

                var row1 = rows.select("li:nth-child(0)");
                var row2 = rows.select("li:nth-child(1)");
                var row3 = rows.select("li:nth-child(2)");
                var row4 = rows.select("li:nth-child(3)");

Open in new window

The issue with the code above is that each child show the same text and add the last text from the previous row.
My question:
How can I get the text from each dynamic li.?

thanks ,

Avatar of undefined
Last Comment
Moti Mashiah

8/22/2022 - Mon
Lokesh B R

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Moti Mashiah

Thank you for your answer, but I found the way of doing it:

var ul1 = $("#addnew_product li:nth-child(1)");
var ul2 = $("#addnew_product li:nth-child(2)");
var ul3 = $("#addnew_product li:nth-child(3)");

after user finish to insert row dynamically I just take all the child from another method.

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.