html - hide specific divs after clicking on other div using jQuery -


i quite new in jquery.

i have html code below generated on fly , added page:

 <div class="outstandingcallback"> <span>a</span> <span>b</span> </div> <div class="outstandingcallback"> <span>c</span> <span>d</span> </div>     ...... 

i need hide 1 of them when click on other one. used following jquery not sure how can hide div element.

     $('.outstandingcallback').bind('click', function () {                 var selectdcallitemid = $(".callitemid", this).html();                   var myhtmlcode = $('#callbacks').html();                  $('' + myhtmlcode + '').find('div').each(function () {                     var thiscallid = $(".callitemid", this).html();                      if (thiscallid == selectdcallitemid ) {                         alert("test");                         $('' + myhtmlcode + '').find(this).hide();                     }                 });             }); 

i not sure following part:

     $('' + myhtmlcode + '').find(this).hide(); 

you can use .siblings() find other elems @ same level:

because which generated on fly , added page use .on , delegate event closest existing parent or document

 $(document).on('click', '.outstandingcallback', function () {     $(this).siblings('.outstandingcallback').hide();  }); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -