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?

14th Dec 2018, 1:22 PM
Ravindra Desai
Ravindra Desai - avatar
2 Answers
14th Dec 2018, 3:34 PM
CalviŐ˛
CalviŐ˛ - avatar
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
14th Dec 2018, 2:00 PM
suraj patel