I’m trying to do some regular click function, where I have to find an element outside of the clicked element. Here is some code:
<div class="options">
<span class='comment_now'>kommentér</span>
</div>
<div class="write_comment_wrap">
<form method="post" class="write_comment_form">
<textarea class="write_comment" name="write_comment" placeholder="skriv din kommentar..."></textarea>
<input type="submit" value="skriv" class="global_button">
</form>
</div>
JS :
$('.comment_now').click(function(){
$(this).closest('.write_comment_wrap').slideToggle();
});
Nothing is happening. I’ve tried to make an alert to find out if I’m inside of the function. I guys I’m using the wrong traversing function.
try :
demo : http://jsfiddle.net/HwQLw/