搜尋

首頁  >  問答  >  主體

javascript - load()方法持續載入問題

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

全部回覆(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
  • 取消回覆