How can I change an element’s class with JavaScript?

Modern HTML5 Techniques for changing classes Modern browsers have added classList which provides methods to make it easier to manipulate classes without needing a library: Unfortunately, these do not work in Internet Explorer prior to v10, though there is a shim to add support for it to IE8 and IE9, available from this page. It is, though, getting more and … Read more

How to close current tab in a browser window?

You will need Javascript to do this. Use window.close(): Note: the current tab is implied. This is equivalent: or you can specify a different window. So: with HTML: or: You return false here to prevent the default behavior for the event. Otherwise the browser will attempt to go to that URL (which it obviously isn’t). Now the options on … Read more

Adding options to a