jquery - Click function, inside .off removed handler, want it back -


need help.

i want to:

  1. click on div makes .active
  2. click on span inside div removes .active div

there's demo of way tried this:

http://jsfiddle.net/2rwjj/

$('div').on( 'click', function() {    if (!$(this).hasclass('active'))      $(this).addclass('active');    // span pressed   $('div.active span').click( function() {     $('div.active').off();                         // removing div handler     $('div.active').removeclass('active');  }); }); 

problem: once i've clicked div , span in it, i cannot click jquery action further times, once in element

am doing wrong handlers? please tell me how this.

try this

$( function() {    $('div').click(function() {      if (!$(this).hasclass('active'))        $(this).addclass('active');   });      // x pressed  $('body').on('click','div.active span', function() {           $(this).parent().removeclass('active');     }); });  

demo here


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -