1

The following JavaScript function is supposed to make a simple JQuery call to load a page and set a class:

function Lp(page,class) {
    $("#result").load(page);
    $('#nav').attr('class',class);
}

However it failed to work until, on a hunch, I changed the name of the second parameter:

function Lp(page,hilite) {
    $("#result").load(page);
    $('#nav').attr('class',hilite);
}

Surely the parameter names are arbitrary, or am I missing something?

1
  • 1
    Doesn't your error console tell you what's wrong with that? Commented Jul 16, 2012 at 18:32

1 Answer 1

5

class is a reserved keyword in JavaScript. That's why.

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

Comments

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.