Use javascript to get the style of an element from an external css file
Posted
by Alan
on Stack Overflow
See other posts from Stack Overflow
or by Alan
Published on 2010-04-01T04:06:09Z
Indexed on
2010/04/01
4:13 UTC
Read the original article
Hit count: 213
I have a html like this:
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="style.css">
</head>
<body>
<div id="test">Testing</div>
<script>
alert(document.getElementById('test').style.display);
</script>
</body>
</html>
The style.css:
div {
display:none;
}
I expect the js would return "none", but it return an empty string instead. Is there any way to solve this problem?
© Stack Overflow or respective owner