Everybody knows how to do this using jQuery. But what if you didn’t want/need to use jQuery in your project. There could be a legitimate reason for this and you just wanted to knock out some quick javascript and move on. Well, here’s a cross browser, backwards compatible method that will let you do just that:
[pretty_gist id="4380650"]
Credit goes to Kevin Yank who came up with this function.