Is it possible to get the css-width value of the first element no matter what that element is?
Is it possible to get the css-width value of the first element no matter what that element is?
I've attempted with .slice(0,1) & first(). These two functions dont' seem to work well with spans
Here is the jsfiddle example
http://jsfiddle.net/x3KrL/2/
- <!DOCTYPE html>
<html>
<head>
<style>.highlight{background-color: yellow}</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p><div style="width:34px;">Look:</div> <div>This is some text in a paragraph.</div> <div>This is a note about it.</div></p>
<script>
$("p div").first().addClass('highlight');
alert( $("p div").first().css('width') );
$('p div').slice(0,1).css('background-color', 'red');
</script>
</body>
</html>
I'll have you know, this does not work. Not at all.
--- Keysle