javascript - on .bind('click') it is not deleting the first div -


When I click on a particular div, it is easy to fade out that div, Clicking on Divine

HTML code

   

jQuery code are sel_id, sel_1 variables

  $ ('. Selc_d'). FadeOut ('slow'); $ ('#' + sel_id) ('' 'sel_id = $' ('. Sel')) Att ('id' ('' click ', function $ (' # '+ Sel_id) '); Alert (sel_id) .remove (); $ (' search_box '). Attachments (sel_1);});  

  $ ('. Sel'). Dam ('click', function () {var sel_id = this.id; // to this line using this.id or $ (this) .attr ('id'); alert (sel_id); $ (' # '+ Sel_id) .FadeOut (' slow '); $ (' # '+ sel_id) .remove (); $ (' search_box '). Attachment (sel_1);}); This  

this ... element of this will be included in it.

What were you doing

  var sel_id = $ ('. Sel'). Attr ('id');  

which will always select the first div with the code sel5

in this code

# # What do you want ##

  & lt; Div id = "selc_d" class = "selc" style = "position: full; left: 15px; top: 200px; width: 260px;" & gt; & Lt; Div id = "sel5" class = "sel" & gt; Some & lt; / Div & gt; & Lt; Div id = "sel6" class = "sel" & gt; Some & lt; / Div & gt; & Lt; Div id = "sel7" class = "sel" & gt; Some & lt; / Div & gt; & Lt; / Div & gt; $ ('. Cell'). Bind ('click', function) {var sel_id = $ (this) .attr ('id'); Alert (sel_id); $ ('#' + Sel_id) FadeOut ('slow'); $ ('#' + Sel_id) .remove (); $ ('. Search_box'). Attachment (sel_1);});  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -