jquery - How do I remove list items that have been added by append? -
I want to be able to add objects to an unshared list (wibble) when a large list of items (user_checkboxes) Is selected from). If a user clicks on an item in the 'wibble' list, I would like to remove that item from the list.
The problem I have is that the list works as 'A' and 'B' items I was hoping for. That means if I click on the list item, they are removed from the list. Unfortunately, any items that are added to the list from the app do not behave in the same way. That is, they are not selected and removed from the list. When you click the Use instead: This connects an event handler to & lt; Ul class = "wibble" & gt; & Lt; Li & gt; & Lt; / Li & gt; & Lt; Li & gt; B & lt; / Li & gt; & Lt; / Ul & gt; $ (Document) .ready (function () {$ (". User_checkboxes"). Change (function () {if ($ (this) .attr ("checked")) {$ ('.wibble'). '& Lt; li & gt; '+ newListItem +' & lt; / li & gt; ';)}} $ (' .wibble li '). Click (function () {$ (this) .remove ();) ;}
click event handler Do not list elements still exist, so jQuery can not bind any handlers with them.
$ ('.wibble'). Representative ('li', 'click' function () {$ (This) .remove ();});
.wibble (which does Is present) and hears any clicks that arise from the
li element of the line.
Comments
Post a Comment