Reputation: 1
On page load, i have two div blocks "replyComment" and "tobereplaced"
<div id="replyComment">
<form id="myForm" name="myForm" method="post" action="reply.php" >
<textarea name="suggestions" rows="5" cols="60" style="resize:none" onfocus="this.value=''">Enter your reply here</textarea>
<input type="hidden" name="hidden">
<input type="hidden" name="hidden2" >
<a href="blog.php?page=hm"><img src="html_images/cancel.png" onmouseover="src='html_images/cancelhover.png'" onmouseout="src='html_images/cancel.png'" alt="Cancel"/></a>
<input type="image" name="Post" value="Reply" alt="Reply" src="html_images/reply.png" onmouseover="src='html_images/replyhover.png'" onmouseout="src='html_images/reply.png'"/>
</form>
</div>
<div name="tobereplaced">
<img src="html_images/reply.png" class="ajax-func" onmouseover="src='html_images/replyhover.png'" onmouseout="src='html_images/reply.png'" />
</div>
and i am trying to hide the replyComment div on load and toggle it to show on click of tobereplaced with the following jquery.
$(document).ready(function () {
$(".replyComment").hide();
$(".ajax-func").click(function(evt) {
$(this).prevAll(".replyComment:first").slideToggle("fast");
$(this).toggleClass("active");
return false;
});
});
but the replyComment is not hidden on page load nor does it toggle..i am new to jquery, any help will be appreciated..
Upvotes: 0
Views: 48
Reputation: 400
Your selector is wrong. ".replyComment" matches a tag with the class replyComment.
For the id you sould the selector "#replyComment".
Try studing a little bit more selectors, they are the soul of jQuery and browse http://jqapi.com/ for references.
Upvotes: 0
Reputation: 51937
You use the dot selector if you're referring to an element by its class and the hash selector to refer to an element by ID. So in your case, you should have:
$('#replyComment').hide();
Upvotes: 3
Reputation: 39522
Your div is an id
, but your selector is looking for classes. Try this:
$("#replyComment").hide();
Upvotes: 1