I want to specify the .second_div width of the first_div , but the problem is that the first div doesn't have the width value specified in css, and I need to find its width using jQuery.
HTML:
<div class="first_div">First Div</div> <div class="second_div">Second.width == First.width</div>
CSS
.second_div, .first_div { border: 1px solid black; padding: 2px 4px; display:inline-block; }
JQuery
$(document).ready(function(){ $(".second_div").css({'width':($(".first_div").width()+'px')}); });
jsfiddle: https://jsfiddle.net/ekqecjb8/1/
Valip source share