简体   繁体   English

未捕获的 ReferenceError:{function ONCLICK} 未在 HTMLAnchorElement.onclick 中定义

[英]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.

相关问题 未捕获的 ReferenceError:未在 HTMLAnchorElement.onclick 中定义 - Uncaught ReferenceError: is not defined at HTMLAnchorElement.onclick 未在 HTMLAnchorElement.onclick 中定义未捕获的 ReferenceError - Uncaught ReferenceError not defined at HTMLAnchorElement.onclick 未捕获的 ReferenceError:在 HTMLAnchorElement.onclick 中未定义犯罪 - Uncaught ReferenceError: Crime is not defined at HTMLAnchorElement.onclick 未捕获的ReferenceError:在HTMLAnchorElement.onclick中未定义添加 - Uncaught ReferenceError: add is not defined at HTMLAnchorElement.onclick 未捕获的 ReferenceError:在 HTMLAnchorElement.onclick 中未定义 buyNft - Uncaught ReferenceError: buyNft is not defined at HTMLAnchorElement.onclick JS 错误 Uncaught ReferenceError: 'name' is not defined at HTMLAnchorElement.onclick - JS error Uncaught ReferenceError: 'name' is not defined at HTMLAnchorElement.onclick 未捕获的 ReferenceError: setStatusClosed 未在 HTMLAnchorElement.onclick (index.html:1) 中定义 - Uncaught ReferenceError: setStatusClosed is not defined at HTMLAnchorElement.onclick (index.html:1) 未捕获的 ReferenceError:$ 未在 HTMLAnchorElement.onclick 中定义(VM#### index.html:1:11) - Uncaught ReferenceError: $ is not defined at HTMLAnchorElement.onclick (VM#### index.html:1:11) 出现错误“(索引):1未捕获的ReferenceError:<func_name> 单击删除按钮时未在 HTMLAnchorElement.onclick ((index):1:1)" 处定义</func_name> - Getting Error "(index):1 Uncaught ReferenceError: <func_name> is not defined at HTMLAnchorElement.onclick ((index):1:1)" on clicking delete button 未捕获的 ReferenceError:在 HTMLAnchorElement.onclick (VM852:14) 中未定义 onSelect - Uncaught ReferenceError: onSelect is not defined at HTMLAnchorElement.onclick (VM852 :14)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM