if ($("#testCell").css("display") == "block")
or
if ($("#testCell").css("display").indexOf("table") == -1)
Here is a full example to set a string to be used as a style, depending on the support for a particular CSS style, not useragent parsing or object detection.
<html>
<head>
<style type="text/css">
table td
{
border:solid 1px black;
border-collapse:collapse;
padding: 1px;
}
.cg1 {
width:150px;
display:inline-table;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
// This value is updated when the document is loaded is inline-table style is not supported
var showStyle = "inline-table";
function cssTest() {
if ($("#testCell").css("display").indexOf("table") == -1) showStyle = "inline";
alert (showStyle);
}
</script>
</head>
<body onload="cssTest()">
<table>
<tr>
<td class="cg1" id="testCell">Test Cell</td>
</tr>
</table>
</body>
</html>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)