1

When i try to do this:

if (window.location.hash) {
  current_page = window.location.hash;
}
$(current_page).siblings('.page').css(display: 'none');

current_page would be e.g #hello, so i dont think removing the # is necessary, since i am using ID's to identify the element.

This is my error in chrome:
Uncaught SyntaxError: Unexpected token:
I don't get more than that.

I've read other questions on here about how to use variables in selectors, and it should work. I've also rewritten it twice to make sure there's no hidden characters.
Does anyone know what's wrong?

1
  • Well what's in window.location.hash? -> console.log(window.location.hash) Commented Feb 22, 2013 at 15:12

2 Answers 2

2

Sure, it's not:

.css(display: 'none');

but

.css('display', 'none');

or

.css({display: 'none'});

or

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

1 Comment

Argh, thought it was something wrong with the variable. Accepting as soon as I can!
1

Your syntax inside the css() call is wrong, use this:

$(current_page).siblings('.page').css('display', 'none');

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.