I want to get height ( or width.. doesnt really matter ) from element A
and use that height to set css to element B
...like
$('#element_B').css({ 'top','element_A_height' })
A little example here.. I know the javascript is not even close to something that works, I just tried to explain what i wanted to happen..
http://jsfiddle.net/cJdXg/
I have no idea how to achieve this.. any ideas?
Here's an example of what you want to achieve: http://jsfiddle.net/cJdXg/2/
HTML:
<div id="BoxeeBox">Lorem ipsum dolor. #boxeeBox</div>
<div id="emptyBox1">#emptyBox1</div>
<div id="emptyBox2">#emptyBox2</div>
JavaScript:
var BoxeeBox = $('#BoxeeBox'); /* cache the selector */
$('#emptyBox1').css({ width: BoxeeBox.width() });
$('#emptyBox2').css({ height: BoxeeBox.height() });
CSS:
div { background: #b6d754; color: #ffffff; padding: 10px; margin: 5px; float: left; clear: both; border-radius:10px; }
What you're after is this:
http://api.jquery.com/height/
Example:
var elementAheight = $('#elementA').height();
however, if elementA has margins you may want to us this:
http://api.jquery.com/outerHeight/
Example:
var elementAoutheight = $('#elementA').outerHeight();
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With