SyntaxFix
Write A Post
Hire A Developer
Questions
It doesn't work because it's syntactically nonsensical. You simply can't do that in JavaScript like that.
You can, however, use jQuery:
if ($(this).is('[href$=?]'))
You can also just look at the "href" value:
if (/\?$/.test(this.href))