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

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -