June 11, 2019 at 5:40 am #291345
I know it’s a long time since Chris wrote the ‘Transformer Tabs’ article, but I’ve only been following it up today.
The HTML displays OK, and the supporting CSS and JS are loading. I’m getting no action on the tabs, but I’m seeing an error on the Inspector Console:
Error: Syntax error, unrecognized expression: [href=#tab-2] jquery-3.4.0.js:1563:8, which expands to:
As far as I can see I’ve pasted the code correctly. The offending line seems to be: var anchor = $(“[href=” + hash + “]”);
OR possibly the value of ‘hash’
I’m still looking for the solution, but I’d really appreciate some help, please.
Tim DawsonJune 11, 2019 at 8:13 am #291349
OK, I’ve figured it out.
The given code in ‘changeTab (second line) reads: var anchor = $(“[href=” + hash + “]”);
and it should be: var anchor = $(“[href='” + hash + “‘]”);
note addition of single quotes around the variable hash, so it now evaluates as href=’hashvalue’
I can’t explain why the Code Pen works!
You must be logged in to reply to this topic.