jquery - Issues with removing attribute from first click(function()) after the second click(function()) -


evening ladies , gents,

i'm in bit of pickle trying figure out how remove attribute first click function after second click function has occurred.

<script type="text/javascript"> $(document).ready(function(){  $('.description').hide();  $('.open').click(function(){     $(this).attr('id', 'active');       $('.description').hide();      var section = $(this).attr('rel');     $(section).slidetoggle('fast'); });  $('.close').click(function(){     $(this).parents('.description').slideup('fast');      $('.open').removeattr('id', 'active');    }); }); </script> 

what mean while have close button on hidden div works once has been clicked (ie. removes attribute .open class), can't see work if hidden div closed clicking next click function.

i'm not explaining myself well, perhaps example easier:

click function issues here

i've created divs first 2 menu items (cashier & deli), 2 examples i'm going use. if click on cashier item, hidden div appears , if press "close" on div (aligned right), active state disappears on first menu item. great. works.

but, if decide close hidden div not "close" link, clicking next menu item (deli), both cashier , deli menu items stay active. again, question whether can somehow remove when second click function on second menu item occurs.

thanks in advance!

you following bad approach removing id attribute can perform same task easily.

also see using sprites , have associated images in place it..

so try approach..

$('.description').hide();  $('.open').click(function(){     var $this = $(this);     $('.description').hide();      $this.addclass('active');     // select open tags     var $tags = $('.open').not($this);     // remove active class items except clicked open     $tags.removeclass('active');      var section = $(this).attr('rel');     $(section).slidetoggle('fast'); });  $('.close').click(function(){     $(this).closest('.description').slideup('fast');      $('.open').removeclass('active'); }); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -