I have two containers with text in them, and I'm trying to get their widths and add them together. I've set up a jsfiddle but it doesn't seem to work at all and I'm not sure why. I've used both width() and innerWidth().
this is the fiddle: http://jsfiddle.net/a83C6/
and this is the code:
HTML:
<div class="text-1">hello</div>
<div class="text-2">hello</div>
<div class="length"></div>
CSS:
.length {
border:1px solid red;
height:5px;
}
JS:
$(document).ready(function() {
$(".length").css({
width:$(".text-1").innerWidth() + $(".text-2").innerWidth()
});
});