Monday, May 09, 2005

How to know current style?

How to know current style?

<script language="JavaScript" type="text/javascript">
function checkStyle(node) {
if (document.all) {
alert(node.currentStyle.fontStyle);
} else if (window.getComputedStyle) {
alert(window.getComputedStyle(node,null).getPropertyValue("font-style"));
}
}
</script>

<em onclick="checkStyle(this)">This is italic. Try to click me.</em>

No comments: