0
Remove an item from a list in JavaScript..
Consider a list of items..now i want to remove that item from the list on which the user has clicked.. what'll be the javascript code for this?
2 Antworten
+ 1
Here is another example
https://code.sololearn.com/W5os0a1pX5d9/?ref=app
0
here is the most common way;
1) give id to the ol or ul tha
2)give ids to li items by either defining it on html or using a setup function . whatever method you want to use.
3)create a function to generate event listeners for all the li items
4)store the li item in a var using something like this .and remove it
inside the event listener((e)=>{
document.getElementById(''ol or ul id'').removeChild(e.target)
}
)
https://code.sololearn.com/WEM8U1l1M60n/?ref=app