Reputation: 1816
I have comment form for every posts. I would like to show the input box only if the comment link is clicked.
$("*#comment_form").hide();
$(".comment_link").click (function(){
$("#comment_form").show(); // problem here...
});
I have used this script above to hide all comment boxes ( comment div) on page load. and when the comment link is clicked, i want to show one comment box for that particular post.
<a class="comment_link href="#">Comment</a>
<div id="comment_form">
<form id="form_comment" action="docomment.php" method="post">
<input type="text" name="comment">
</form>
</div>
Upvotes: 1
Views: 1836
Reputation: 9031
works perfect if you just fix your HTML markup: http://jsfiddle.net/voigtan/QAvKT/
added a css class instead if you are using more form elemens in your document at once: http://jsfiddle.net/voigtan/QAvKT/3/ (added a preventDefault on your a-elements)
Upvotes: 4