The intent is: onclick to check which background image is currently used by clicked class and change it to the other image. -------------------------- $('.details_box_trigger').click(function() { var original_image = 'url(../images/arrow-hide.png)'; var second_image = 'url(../images/arrow-show.png)'; if ( $(this).css('background-image') == original_image) //For some reason this IF is never True!!! { $(this).css('background-image', second_image); } else { $(this).css('background-image', original_image); }; return false; }); ------------------------
Could you, please, take a look: -------- $(document).ready(function() { $('div#view').hide(); $('div#slide').toggle(function() { $(this).siblings('div#view').fadeIn('fast'); } , function() { $(this).siblings('div#view').fadeOut('fast'); return false; }); $('button#exp').click(function() { $('div#view').show(); }); $('button#clp').click(function() { $('div#view').hide(); }); -------
The issue is: Do 'expand all' or 'collapse all'(#exp click or #clp click)=> Click toggle for a separate div#view to observe that it does not toggle=> Click again to observe that it toggles.
Noticed in FireBug that upon toggling there is a 'lastToggle' flag that is switched (it has two states '1' and '2'). Now after 'collapse all' or 'expand all' I click on div#slide to show/hide the div#view and nothing happens but the 'lastToggle' is switched. Clicking once again does the job...