Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery回调函数(updatepanel内部)不平滑_Javascript_Jquery_Asp.net_Ajax_Updatepanel - Fatal编程技术网

Javascript Jquery回调函数(updatepanel内部)不平滑

Javascript Jquery回调函数(updatepanel内部)不平滑,javascript,jquery,asp.net,ajax,updatepanel,Javascript,Jquery,Asp.net,Ajax,Updatepanel,我有一个jquery函数来切换“ReplyComment”div 喋喋不休 喋喋不休 此功能有时工作,有时不工作。短期内无法顺利工作。 我不明白。(在updatepanel和datalist中)您可能多次添加单击处理程序。为了完全避免此问题,我建议使用事件委派: $(document).ready(function() { $(document).on('click', '.in', function () { var $this = $(this),

我有一个jquery函数来切换“ReplyComment”div

  • 喋喋不休
  • 喋喋不休
此功能有时工作,有时不工作。短期内无法顺利工作。
我不明白。(在updatepanel和datalist中)

您可能多次添加单击处理程序。为了完全避免此问题,我建议使用事件委派:

$(document).ready(function() {
    $(document).on('click', '.in', function () {
        var $this = $(this),
            $reply = $this.next('.ReplyComment');
        var cevapladisplay = $reply.css('display');
        $reply.toggle();

    });
});

这将防止您在每次
UpdatePanel
刷新后需要重新绑定事件。

更新Panel在哪里?@未定义如何修复它:/@JasonP UpdatePanel>datalist>ul
<ul class="chats">
 <li class="in" >
        blablabla
 </li>
 <div class="ReplyComment" id="ReplyComment">
     blablabla
 </div>
 </ul>
$(document).ready(function() {
    $(document).on('click', '.in', function () {
        var $this = $(this),
            $reply = $this.next('.ReplyComment');
        var cevapladisplay = $reply.css('display');
        $reply.toggle();

    });
});