question

NepaBort-8609 avatar image
0 Votes"
NepaBort-8609 asked ZhiLv-MSFT edited

add and remove duplicate <div>

I'm trying to build a budget evaluator app that will run in a browser. I've been trying to learn javaScript and/or jQuery and other scripting languages for a long time. I've never been able to make any sense of or understand it at all. I'm completely lost. I'm not a professional developer, never had and don't want a job (I'm retired) as a software engineer or coder. I enjoy doing it. It's a hobby. I find it fun most of the time. I continue to get frustrated when I need javaScript of jQuery because I just can't get it.

I have this so far. How do I get the minus buttons that get duplicated with the div's to remove the row they're next to?
Every way I've tried so far in the last few days I've been researching online to try and figure it out hasn't worked.



https://codepen.io/Sickxiczix/pen/RwMbZEJ

dotnet-aspnet-generaldotnet-aspnet-core-mvc
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ZhiLv-MSFT avatar image
0 Votes"
ZhiLv-MSFT answered ZhiLv-MSFT edited

Hi @NepaBort-8609,

Try to modify your code as below: 1. Set the unique Id attribute. 2. Add click function for each "+" button 3. Add the remove button click event:

215628-image.png

Then the JS script is like below:

215608-image.png

view the source code: 215652-sourcecode.txt

The result:

215653-1.gif


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Dillion



image.png (214.2 KiB)
image.png (94.4 KiB)
sourcecode.txt (2.6 KiB)
1.gif (82.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.