无法触发点击事件

时间:2014-11-14 19:45:03

标签: javascript jquery

我正在尝试在调用函数时执行触发器。如果调用了一个页面(www.example.com/search),我想查看是否有一个有效的参数传递给它。如果是,它将触发点击事件以加载该页面数据,但它似乎没有点击。我测试了循环,一切都很好。只是最后的事件不会点击链接。任何人都可以看到任何问题吗?

// the valid pages this can be used with
var valid_pages = ["search", "users"];

//the valid final param that can be used to make a click
var valid_params = ["menu", "deals", "reviews", "uploads", "activity", "followers", "following"];


if (inArray(page_param, valid_pages) === true) {

    //if the final param in the url string is valid then simulate the click event
    if (inArray(url_element, valid_params) === true) {

        //loop over the menu buttons
        $('.menu_button').each(function () {

            //if there is a valid url element click its link
            if ($(this).data("link-command") == url_element) {

                    $(this).trigger("click");
            }

        });
    }

}

0 个答案:

没有答案