Friday 15 July 2011

Jquery each function and click event not working -


I want to remove every element selected from the same class element. My jquery coding is bellow

  $ (". Del_layer"). Each (function () {$ (this). Click (function () {$ (this) .Parent () delete ();});});   

My HTML structure is

  & lt; Li class = "select_layerList" data-refund = "0" & ​​gt; & Lt; Img width = "20px" src = "tmp_card_imgs / a.png" & gt; Layer 0: Image & lt; Span class = "del_layer" style = "cursor: indicator;" & Gt; X & lt; / Span & gt; & Lt; / Li & gt; & Lt; Li class = "select_layerList" data-refund = "0" & ​​gt; & Lt; Img width = "20px" src = "tmp_card_imgs / b.png" & gt; Layer 0: Image & lt; Span class = "del_layer" style = "cursor: indicator;" & Gt; X & lt; / Span & gt; & Lt; / Li & gt;   

but each function is not working

This fix doing work.

Ensure that you have DOM loaded, your code is a document.ready ()

  Put inside $ (document) .ready (function () {});    

No comments:

Post a Comment