Check if an element contains a class in JavaScript?

Use element.classList .contains method: This works on all current browsers and there are polyfills to support older browsers too. Alternatively, if you work with older browsers and don’t want to use polyfills to fix them, using indexOf is correct, but you have to tweak it a little: Otherwise you will also get true if the class you are looking for is part … Read more

Hide text using css

This is one way: Here is another way to hide the text while avoiding the huge 9999 pixel box that the browser will create:

Can you set a border opacity in CSS?

Unfortunately the opacity property makes the whole element (including any text) semi-transparent. The best way to make the border semi-transparent is with the rgba color format. For example, this would give a red border with 50% opacity: For extremely old browsers that don’t support rgba (IE8 and older), the solution is to provide two border … Read more