code snippets

Escaping characters to get a valid jQuery id

jQuery is a very powerful javascript library that I use all the time. For the most part, I find that it's simple to use, yet easy enough to do very advanced things. Anyone who has used jQuery knows that you can do quite a lot with selectors. One of the caveats that I run into often is using a selector for a DOM element that contains special characters. jQuery requires many characters to be escaped in the selector in order to function properly. The problem here is that jQuery doesn't offer a function that will escape your selector value for you. I've created such a function here:

PHP array of American states

I've recently been tasked with creating a US state selection box. Here is a PHP array that I used to generate the html select box. I hope it will save others some time:

Subscribe to RSS - code snippets