But we faced some issues when we tried to use setAttribute for dynamically changing the CSS style class name for a div tag.
i-e We tried to use below code for setting "current" as CSS style class for a div tag with id "desc"
document.getElementById('desc').setAttribute('class','current');
The above code worked in FireFox. But it didn't work in IE (Internet Explorer).
We came to know that we should use ‘className’ instead of 'class' in IE.
So, in IE, the code should look as below,
document.getElementById('desc').setAttribute('className','current');
We have to use javascript code for using the required code based on user's browser.
More Articles...
No comments:
Post a Comment