Reputation: 445
I set up this fiddle with an issue I am encountering. I need the script to hide the button that was clicked after the animation is complete. What is the correct way to do this?
http://jsfiddle.net/digitalaxis/utJKU/
HTML:
<div>
<a id='button1' href="#">Button 1</a>
<a id='button2' href="#">Button 2</a>
<a id='button3' href="#">Button 3</a>
<a id='button4' href="#">Button 4</a>
<a id='button5' href="#">Button 5</a>
</div>
<div id="box">
Some element
</div>
JS:
$('a[id^="button"]').click(function() {
$('#box').hide('slow', function() {
$('a').hide('slow');
});
});
Upvotes: 0
Views: 498
Reputation: 3246
set a global variable where receive $(this)
, and use in the call back, like this:
$('a[id^="button"]').click(function() {
var $this = $(this);
$('#box').hide('slow', function() {
$this.hide('slow');
});
});
Upvotes: 8