Skip to content Skip to sidebar Skip to footer

Divide By Css Calculated Width Instead Of Element Width Attribute With Jquery

I currently have this code: $('.blogimages img').css('marginLeft', function() { return - $(this).width()/2; }); However it's taking the width='750' attribute instead of the n

Solution 1:

You can use outerWidth() - http://api.jquery.com/outerWidth/

Solution 2:

Have you tried getting the css value? $(this).css('width')/2;

Post a Comment for "Divide By Css Calculated Width Instead Of Element Width Attribute With Jquery"