[英]Uncaught ReferenceError: {function ONCLICK} is not defined at HTMLAnchorElement.onclick
I have one page index.php
and the other one include/comments.php
.我有一页index.php
和另一页include/comments.php
。
index.php index.php
<div class="row replybox" style="display:none">
<div class="col-md-12">
<textarea class="form-control" id="rComment" cols="30" rows="2"></textarea><br>
<button style="" class="btn-primary btn" id="addReply">Add Reply</button>
</div>
</div>
<script type="text/javascript">
function reply(x) {
$('.replybox').show();
}
</script>
include/comments.php包括/评论。php
function DisplayComment($data){
return '
<div class="comment">
<div class="useremail">'.$data['email'].' <span class="date_time">'.$data['date'].'</span></div>
<div class="comment">'.$data['comment'].'</div>
<div class="reply"><a href="#" onclick="reply(this)">REPLY</a></div>
<div class="replytext"></div>
</div>
';
}
When I click on the reply link, the following error is displayed当我点击回复链接时,显示以下错误
ReferenceError: reply is not defined at HTMLAnchorElement.onclick ReferenceError:回复未在 HTMLAnchorElement.onclick 中定义
I am not able to show the div ($('.replybox').show();)... Can someone help me.我无法显示 div ($('.replybox').show();)... 有人可以帮帮我吗? thank you.谢谢你。
I think it seems like there is an error in the connection.我认为连接中似乎存在错误。 because you have assigned href to the a tag and the onclick event.因为您已将 href 分配给 a 标签和 onclick 事件。 I will recommend you to try as follows.我会建议你尝试如下。
<div class="row replybox" id="replybox" style="display:none">
<div class="col-md-12">
<textarea class="form-control" id="rComment" cols="30" rows="2"></textarea><br>
<button style="" class="btn-primary btn" id="addReply">Add Reply</button>
</div>
</div>
function DisplayComment($data){
return '
<div class="comment">
<div class="useremail">'.$data['email'].' <span class="date_time">'.$data['date'].'</span></div>
<div class="comment">'.$data['comment'].'</div>
<div class="reply"><button type="button" onclick="reply()">REPLY</button></div>
<div class="replytext"></div>
</div>
';
}
and please try this请试试这个
<script type="text/javascript">
function reply() {
document.getElementById('replybox').style.display = "block";
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.