[jQuery] How to get a css value in "each"
How do you get the values of a jQuery item? I've tried several variations, as shown in the document below. The last two alerts error. The first, in Firefox, gives an "o.getAttribute is not a function". The second says "$(this).style has no properties". Is it possible that the width is not yet set when the document ready function is called?
I thought I saw something in the Mailing List addressing this, but haven't been able to find it.
Thanks.
<html>
<head>
<title>jQuery - Test</title>
<script type="text/javascript" src="
<a href="http://jquery.com/src/latest/">http://jquery.com/src/latest/</a>"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".jqItem").each(function(i){
alert(this.width);
alert(this.style.width);
alert($(this).width);
alert($(this).css("width"));
alert($(this).style.width);
});
});
</script>
<style type="text/css">
.jqItem
{
position: absolute;
bottom: 0px;
width: 200px;
}
</style>
</head>
<body>
<div class="content">
<span class="jqItem">Test getting the width of this item</span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
</div>
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/