C
Ciaran
Consider this:
<html>
<head>
<style type="text/css">
p.ex1 {margin-left:50px;}
</style>
</head>
<body onload="
alert(document.getElementById('ex1').style.marginLeft);
alert(document.getElementById('ex2').style.marginLeft); ">
<p class="ex1" id='ex1'>A paragraph with a 20px left margin.</p>
<p id='ex2' style='margin-left:20px;'>A paragraph with a 20px left
margin.</p>
</body>
</html>
Why is the first alert empty and how can I fix it without adding the
style inline?
Thanks,
Ciarán
<html>
<head>
<style type="text/css">
p.ex1 {margin-left:50px;}
</style>
</head>
<body onload="
alert(document.getElementById('ex1').style.marginLeft);
alert(document.getElementById('ex2').style.marginLeft); ">
<p class="ex1" id='ex1'>A paragraph with a 20px left margin.</p>
<p id='ex2' style='margin-left:20px;'>A paragraph with a 20px left
margin.</p>
</body>
</html>
Why is the first alert empty and how can I fix it without adding the
style inline?
Thanks,
Ciarán