jQuery"点击后"事件

Sal*_*n A 11 javascript jquery javascript-events

我有一个在iframe中打开的链接列表,例如:

<ul id="frameTrigger">
    <li><a target="iframe1" href="aaa.html"><img src="aaa.jpg"></a></li>
    <li><a target="iframe1" href="bbb.html"><img src="bbb.jpg"></a></li>
    <li><a target="iframe1" href="ccc.html"><img src="ccc.jpg"></a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

单击链接,我需要更新另一个div .具体来说,我需要调用一个检查框架src属性并更新div 的函数.如果我这样做:

$("#frameTrigger a").click(function() {
    var iframe = $("iframe[name=iframe1]").get(0);
    console.log(iframe.contentWindow.location.href);
    // the problem here is that that the iframe.window.location will
    // change AFTER this function returns
});
Run Code Online (Sandbox Code Playgroud)

我没有得到预期的结果.

Bra*_*rad 9

我猜你得到旧价值而不是新价值?您可能希望将函数包装在1 setTimeout毫秒内以允许更新通过.