• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript How to triple nest quotes in JS?

wyclef

Active Coder
Hi, how can I triple nest quotes so

JavaScript:
jQuery(".navigation a[href*=#"+rnrSection+"]").parent().addClass("active");

has quotes around the # sign?

I am getting an

Uncaught Error: Syntax error, unrecognized expression: .navigation a[href*=#”+rnrSection+”]

that I think has to do with that.
 

cbreemer

King Coder
I'm not sure why you talk about "triple nest quotes" and "quotes around the # sign" ? I'm not seeing any of that here. Just the straightforward string concatenation

".navigation a[href*=#" + rnrSection + "]"

which looks syntactically correct to me. At least in JavaScript, but I don't know if jQuery has different ideas.
Are you sure the error message pertains to the quotes ? Have you pasted the complete error message ? It looks truncated to me. Could it be the asterisk is wrong ? It looks wrong to me (but I know beans about jQuery). In any case I would recommend some spacing for readability.
Note that if you need nested quotes, you can use ' ' inside " " or vise versa. Or you can escape the inner quotes with a backslash.
 
Top