-1

I need some eye, I'm not seeing it right now and its making me feel foolish..

function whichNavToLightUp()
{
    var p = location.pathname;
    p = p.substring(p.length-1) == '/' ? p.substring(0, p.length-1) : p;
    p.split('/').pop();
    p = p.substring(1);
    p = p.toLowerCase();
    $.each('.navmenu', funtion()
    {
        if($(this).attr('rel') == p)
        {
            $(this).css({"background-position":"-108px"});  
        }
    });
}

line 9 the { after the $.each() is giving me the syntax error, but I don't see why. Where did I break it? Anyone?

5
  • 4
    function is misspelled as 'funtion' -- missing the c Commented Oct 7, 2011 at 16:25
  • 1
    the each runs through a handful of divs with the class navmenu, and reads the rel attributes where if one matches p which is gotten from the URL then it moves the position of the background of the matching div as its a sprite image. Commented Oct 7, 2011 at 16:25
  • @bbg you win the imaginary prize!! thank you. Always the most simplest things get over looked. Commented Oct 7, 2011 at 16:27
  • thank you. Only way I can think of keeping the nav Im working on to stay in its hover state if its actually on that page, kinda like how ya would do it with php and and if-else when ?location == blah Commented Oct 7, 2011 at 16:32
  • 1
    Why are you iterating the characters in the '.navmenu' string? And why do p.split('/').pop();? This has no effect in your code. Commented Oct 7, 2011 at 16:36

1 Answer 1

5

$.each('.navmenu', funtion() should be $.each('.navmenu', function() (missing c)

Sign up to request clarification or add additional context in comments.

5 Comments

Haha, sometimes looking at ones code for a long time makes you miss things like this, posting it on here and having someone else look at it, they take a completely different outlook on ones code; first person: "can't be a typo, I wouldn't do that, must be a real syntax error!", third person: "probably just a silly typo, damn noob!". I've done it myself so many times, just makes you want to punch yourself in the face! :)
@Sparky672: "funtion" v.s. "function". Time for new glasses?
someone gave the same answer above in the comments. But thank you the more eyes the better. :-)
sure, I was fiddling about with fancy code view, thats why it took me longer :P
Well just for going that extra mile I thank you that much more! Im actually waiting on the timmer to run out on the question so I can give it the big ol' green check :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.