开发者

How is it possible that my jQuery code breaks a function *in* Google hosted jquery.min.js?

开发者 https://www.devze.com 2023-02-20 19:46 出处:网络
I am getting an error: Uncaught Syntax error, unrecognized expression: :nth-child from my Google hosted jquery.min.js file.

I am getting an error:

Uncaught Syntax error, unrecognized expression: :nth-child

from my Google hosted jquery.min.js file.

It works when my function is like this:

 var screenPos = "init";
 var screenPos2 = "init";
 var col3 = false;

function projectPos(){

    $(".article").each(function(){
   $(this).find(".theProject").css('left','0px');
   $(this).find(".theExtra").css('left','608px');
    });


    $(".article:nth-child("+screenPos+"+4)").find(".theProject").css('left','-304px');
    $(".article:nth-child("+screenPos+"+4)").find(".theExtra").css('left','-304px');

}

But if I add this into the function:

   if (col3 = true){
   $(".article:nth-child("+screenPos2+"+4)").find(".theP开发者_StackOverflow社区roject").css('left','-304px');
   $(".article:nth-child("+screenPos2+"+4)").find(".theExtra").css('left','-304px');
   }

I suddenly get this error from within the google hosted jquery file.

How is that possible? I already have a few nth-child checks in there, so why would a third one break it?

Very curious.

The page in question is here: marckremers.com/2011

PS - the site is in development, I'll leave the error in there, commented out, for reference


if (col3 = true) should'nt be if (col3 == true)?


You appear to be sending init4 as the parameter to nth-child(). As far as I can see, that's not a legal value.

If the value of screenPos2 is being modified elsewhere before this is called, then you need to log that.

0

精彩评论

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