Blub
Blub

Reputation: 13614

How do I set inline styles in internet explorer?

In all other browsers, element.style seems to work fine. But Internet Explorer 8 doesn't know it...

Getting this error when x is a div:

Error: 'x.style.left' is null or not an object

x.style itself is undefined. I looked at http://www.quirksmode.org/dom/changess.html but it doesn't say anything about styles on specific elements, just like http://help.dottoro.com/ljuefnvw.php doesn't say anything either.

Upvotes: 0

Views: 489

Answers (2)

Tom van der Woerdt
Tom van der Woerdt

Reputation: 29975

<div id="example">
    Test
</div>
<script>
    document.getElementById('example').style.marginLeft = '50px';
</script>

works

Upvotes: 3

Charming Prince
Charming Prince

Reputation: 489

instead of using element.style, use the specific tag name.

Upvotes: 0

Related Questions