在页面加载时,我有两个div块"replyComment“和"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>
我试图在加载时隐藏jquery,并将其切换为在单击时显示,其中包含以下replyComment。
$(document).ready(function () {
$(".replyComment").hide();
$(".ajax-func").click(function(evt) {
$(this).prevAll(".replyComment:first").slideToggle("fast");
$(this).toggleClass("active");
return false;
});
});
但是replyComment不会在页面加载时隐藏,也不会进行切换。我是个新手,任何帮助都将不胜感激。
发布于 2012-05-18 20:52:42
如果通过类引用元素,则使用点选择器,而通过ID引用元素则使用散列选择器。因此,在本例中,您应该具有:
$('#replyComment').hide();
发布于 2012-05-18 20:53:04
你的div是一个id
,但是你的选择器正在寻找类。试试这个:
$("#replyComment").hide();
发布于 2012-05-18 20:54:03
您的选择器错误。".replyComment“匹配具有类replyComment的标记。
对于id,您应该使用选择器"#replyComment“。
尝试学习更多的选择器,它们是jQuery的灵魂,请浏览http://jqapi.com/获取参考资料。
https://stackoverflow.com/questions/10659562
复制相似问题