Tag Archives: special character

Using a jQuery selector on an ID containing a Pipe (|) Character Programming 24 FEB 2012

I’m quite fond of using the pipe (|) character in tag, id and name properties because it just seems visually such a great delimiter to use when stuffing a string full of useful information to be extracted via splitting or exploding at a later stage.

However, here’s a nasty one which you might not be aware of – jQuery selectors do in fact no enjoy special characters like the pipe ‘|’ – for the very reason that it’s a special character!

So running a selector on an ID which contains a | in the normal fashion will fail (i.e. not find anything):


To get around identifiers that use special characters like our friend the |, you need to delimit it so:


And now you know! :)

Avoid HTML Special Characters in Your Querystring CodeUnit 13 MAR 2010

I must admit, I was totally left scratching my head a couple of days ago while presenting a survey capturing site I had just finished whipping up, when all of a sudden the site stopped redirecting properly when tested in Internet Explorer (IE) using compatibility mode. Completely flummoxed as to why something that worked perfect fine in some browsers simply didn’t work in others, I stopped to have a quick peek at what might be causing the problem and when I saw what it was, I couldn’t help but break out into laughter.

In order to redirect my script after successfully pushing data into the database, I was using Javascript to change the window’s location to a URL I was specifically building up with some required GET variables attached. However, my ordering of variables in the querystring couldn’t have been more unfortunate had it tried – you see, I was using a variable entitled reg and attaching it to the URL as &reg.

Now those of you with sharp eyes and a little bit of HTML knowledge will immediately slap your heads and go “duh” out loud, because yes, I had managed to accidentally declare a reserved HTML special character, namely ® which is of course translated to the registered trademark symbol. So my querystring was still working but with one less required GET variable as it was being lost in the redirect thanks to the older browser translating it into the actual symbol – hence causing that extreme sense of head-scratching puzzlement I had experienced earlier!

So be a pal and check your variable order in your querystrings carefully. You never know what you might inadvertently creating! :)