开发者

jQuery - Element Matches set in global variables do not work in Google Chrome

开发者 https://www.devze.com 2023-02-28 12:19 出处:网络
I\'ve found a suspicious glitch in my code native only to Google Chrome. I had defined several variables as some elements I commonly referenced, and had no problems executing the code except when in G

I've found a suspicious glitch in my code native only to Google Chrome. I had defined several variables as some elements I commonly referenced, and had no problems executing the code except when in Google Chrome (took me quite awhile to figure out that my variables were caus开发者_开发知识库ing the issue). I am wondering if anyone knows why this is happening..

The following code runs fine in Mozilla, but not in Chrome:

var homeAbout = $("#homeAbout");

$("#subLinkAbout").bind("click", function() { 
    if (homeAbout.is(":visible")) {
        return;
    } 
    $("#content .homeNode:visible").hide("slide", { direction: "right" }, contentSlideTime, function () {
        //this line does not function properly
        homeAbout.stop(true, false).show("slide", { direction: "left" }, contentSlideTime);
    });
});

This however, works fine:

var homeAbout = $("#homeAbout");

$("#subLinkAbout").bind("click", function() { 
    if (homeAbout.is(":visible")) {
        return;
    } 
    $("#content .homeNode:visible").hide("slide", { direction: "right" }, contentSlideTime, function () {
        $("#homeAbout").stop(true, false).show("slide", { direction: "left" }, contentSlideTime);
    });
});

This only appears to happen on the one line where .show() is used. The content will be hidden, and then nothing will happen afterwards. Can anyone explain this further? Any suggestions on my code are also greatly appreciated, I am still very novice when it comes to jQuery...

Thanks very very much in advance, any advice is appreciated.


If you are using jQuery why are you using bind?

$("#subLinkAbout").click(function() { 

Should be better.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号