Reputation: 27087
Is there anything wrong this code. Tried and tested a hundred times.
<a href="#comment_magic" id="comment_magic_1" name="comment_magic_1" class="u">0 comments</a>
<div id="open_sesame_1" style="display:none" class="open_sesame_1">
test
</div>
jQuery:
$("#comment_magic_1").click(
function () {
$("#open_sesame_1").slideDown();
}, function () {
$("#open_sesame_1").slideUp();
});
Upvotes: 0
Views: 1002
Reputation: 5672
click() doesn´t take two event handlers.
.click( handler(eventObject) )
handler(eventObject) A function to execute each time the event is triggered.
You can use slideToggle() instead.
$("#comment_magic_1").click(function() {
$("#open_sesame_1").slideToggle();
});
Upvotes: 1
Reputation: 10619
You have given your div css display none
, and then you are sliding it up and down. Since it is no where visible you don't see the action happening. In your jquery add css display:block
onclick and then it will slide up and slidedown.
Something like this:
Upvotes: 1
Reputation: 11822
In case I get you right and you want the slideUp to trigger on second click, you cannot pass a second handler function to the click-binder. Instead you could use slideToggle()
that will either show or hide the selection based on its current visibility.
Like:
$('#comment_magic_1').click(function(){
$("#open_sesame_1").slideToggle();
});
See: http://api.jquery.com/slideToggle/ and http://api.jquery.com/click/
Upvotes: 1
Reputation: 318182
Try this instead:
$("#comment_magic_1").click(function() {
$("#open_sesame_1").slideToggle();
});
Fiddle : http://jsfiddle.net/adeneo/hxS3d/
Upvotes: 1