Reputation: 869
i am creating div using DOM Element
as
phototab = document.createElement('div');
phototab.setAttribute('class', 'phototab fleft');
//phototab.className = "phototab fleft";
i tried both methods but it is not adding class in IE7
Upvotes: 2
Views: 1286
Reputation: 413836
You can't use setAttribute()
to affect things that are actually properties of DOM elements.
phtototab.className = 'phototab fleft';
should work. (It's an IE thing; other browsers are less picky, but for IE a property is a property and an attribute is an attribute.)
edit — I should say that you shouldn't use .setAttribute()
when it's unnecessary.
Upvotes: 3
Reputation: 94339
How about jQuery?
phototab = $("<div>").addClass("phototab fleft");
That's all! Very simple. :)
Upvotes: -1