jquery - $('p').remove(); doesn't work, why? -


I have this jQuery code, and what I am trying to do is "item" with "code" To add value as .append () method, which I take from an input text box, and then in a list with "lista" in the div as "class" in the "boton" In the form of ID, input it after clicking on it all works well, the problem occurs when I try to delete the item that I $ ('This'). Remove (); Nothing like this

Is there no reason that he is not working? I appreciate any help. Click the

$ {document} .ready (function () {var contador = 1; $ ('# boton') (function () {var item = $ ("input: text" ). Val (); if (item! == "") {$ ('.lista'). App ("& lt; p style = 'Cursor: pointer;' & gt;" + contador + "AC)" + $ ("Input: text"). Val () + "& lt; / p & gt;") contador ++;}}); $ ("P") Click (function () {$ (this) .remove ();}); });

You need to use here because your article has been dynamically added:

  $ ('.lista'). ('Click', 'p', function () {$ (this) .remove ();});   

This will help you to force click events in these newly created paragraphs.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -