javascript - Jquery change iside div width size, based on outside div size -
hi change value of div width, based on outside div width
i new in jquery , javascript , tried code:
if ($('col-md-4 col-sm-6').width() <= 320 ){ $('.card-info').width(120px) };
but didn't work...
the html is:
<div class="col-md-4 col-sm-6"> <div class="card-info"> </div> </div> <div class="col-md-4 col-sm-6"> <div class="card-info"> </div> </div> (...)
could 1 me find out how that, change div "card-info" 120px width if div "col-md-4 col-sm6" 320px or less.
thanks lot.
you're not selecting col-md-4 , col-sm-6 class in jquery. missed dot(.) before $('col-md-4 col-sm-6')
col-md-4
here , comma(,) , dot before col-sm-6
. solution
if ($('.col-md-4, .col-sm-6').width() <= 320 ) { $('.card-info').width(120); }
or
if ($('.col-md-4, .col-sm-6').width() <= 320 ) { $('.card-info').css('width', '120px'); }
Comments
Post a Comment