JG Vimalan's Blog

It is all about coding!

Setting css class with javascript

In this post, I am going to explain about setting css class for controls using javascript.

The following javascript will give you an idea of setting css class to a control for IE and other browsers.

//Javascript

var anchl = document.getElementById(‘largeFontSwitch’); //Id of the control

//Remove class
anchl.setAttribute(“class”, “”); //Other browsers
anchl.className = “”; //IE

//Set class

anchl.setAttribute(“class”, “selectedFont”); //Other browsers
anchl.className = “selectedFont”; //IE

Advertisements

September 6, 2011 - Posted by | JavaScript

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: