我正在使用
之类的评论<div>
<div>
Some message over here
</div>
<div style = "height:10px;"> <a id = "post_id_1" class = "showReply" href = "javascript: void(0)">Reply</a></div>
</div>
我的回复栏
<div id="replymsgbox" style="display: none;">
<form id="frmComment" novalidate="novalidate" method="POST" name="frmComment">
<div>
<textarea id="comment_text" class="" name="comment[text]"></textarea>
<div id="error_text"> </div>
</div>
<div>
<input type="submit" value="Post" name="Submit">
</div>
</form>
</div>
我的Jquery:
//showCommentBox
$('a.showReply').live("click", function(e){
$('#replymsgbox', $(this).parent().next()).slideToggle('fast')
});
任何人都会帮助我。我无法打开回复div或表格。在哪里我做错了
答案 0 :(得分:1)
使用以下最新版本的jQuery。
$('a.showReply').on("click", function(e){
$('#replymsgbox').slideToggle('fast')
});
答案 1 :(得分:0)
$(function() { // if javascript code is before html
$('a.showReply').click(function(e){
$('#replymsgbox').slideToggle('fast')
});
});
答案 2 :(得分:0)
<强> EXAMPLE 强>
$('a.showReply').on("click", function(e){
$('#replymsgbox').slideToggle('fast')
});
您还需要在两个div
之间添加一些填充或空格,以确保内容不重叠。在示例中,我刚添加了<br/>
。
请注意从.live
到.on
的更改,因为它已被弃用。
请参阅Here:
从jQuery 1.7开始,不推荐使用.live()方法。使用.on()来 附上事件处理程序。
将jQuery代码放在$(document).ready(function{ ... })
中,确保文档已准备就绪。我敢肯定你可能已经这样做了,只是粘贴了相关的代码,但总是很好确保。
答案 3 :(得分:0)
$("a.showReply").on("click", function(){
$(this).parent().parent().next().slideToggle("slow");
});
以下是测试:http://jsfiddle.net/2HczB/
我和next()一起使用,因为我看到你尝试用这种方式做的代码。最好立即调用div的id。但是,使用我的解决方案,您可以在单击的邮件回复后准确打开回复。