搜索

首页  >  问答  >  正文

javascript - load()方法持续加载问题

雷雷
習慣沉默習慣沉默2837 天前439

全部回复(2)我来回复

  • 给我你的怀抱

    给我你的怀抱2017-05-18 11:01:05

    // 需要解绑
    $("iframe").attr("src","http://www.szu.edu.cn").unbind().load(function(){
        alert("更新了");
    })

    $(".list-item")有两个class为list-item的元素吧

    回复
    0
  • 滿天的星座

    滿天的星座2017-05-18 11:01:05

    源代码修改为如下即可:

      <!DOCTYPE html>
        <html>
        <head>
            <title>test</title>
            <script src="./jquery.min.js"></script>
        </head>
        <body>
        <button>点击</button>
        <iframe src="http://www.baidu.com" style="height:300px;width:300px;"></iframe>
        <script type="text/javascript">
        $(function(){
            $("button").click(function(event){
                $("iframe").attr("src","http://www.szu.edu.cn").load(function(){
                    $(this).unbind();
                    alert("更新了");
                })
            })
        })
        </script>
        </body>
        </html>
            

    这是局部重复绑定引起的,但是代码具体执行过程我还是没搞明白

    回复
    0
  • 取消回复