0

I have the following code but the click call function is loading before the form loads so its not dynamically updating the results, even though the drop down link option is being correctly selected.

$(window).load(function() {

$("a.optionLink:contains('"+ (document.referrer.split('/').pop()) +"')").click(); });

4

1 回答 1

1

这是由于上面的脚本在 DOM 构建之前运行造成的。由于您使用的是 jquery,因此您应该将此代码移动到 ready 方法中。这将确保 DOM 在执行 click 事件之前准备就绪。

从 jquery 文档...

$(document).ready(function() {
  // Handler for .ready() called.
});

或速记版本...

$(function() {
     // Handler for .ready() called.
    });

有关详细信息,请参阅http://api.jquery.com/ready/

于 2013-07-25T20:19:40.893 回答