I want to set width of a wrapper, so paragraph will be not wider than the image using jQuery. What mistake I made?
$(function(){
$('.wrapper').css({
width: $(this).children('img').width(),
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrapper">
<img src="http://www.placecage.com/400/200"/>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </p>
</div>
<div class="wrapper">
<img src="http://www.placecage.com/500/500"/>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </p>
</div>
<div class="wrapper">
<img src="http://www.placecage.com/300/300"/>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </p>
</div>