Reputation: 85
So, im having some issues with my web; I've got a responsive image slider that works properly if I give him a numeric value, so I made a JS to get this value when i load the web. This is the js :
<script>
$(document).ready(function(){
$('.item').css({
'width': w + 'px'
});
});
</script>
The problem is that it gets the value but dont work as intended.
Here is an img of how it works with the numeric value on css :
And this is what it does when it gets the value with the js.
Any help would be appreciated. Thanks!
P.S. Im using iosslider, cant put the web cause of permissions.
Upvotes: 0
Views: 204
Reputation: 962
Calculating the width of the image on document.ready
may give unfavourabe results, try the width calculation on windows load event
or if feasible to add a vendor JS use images loaded plugin
which will watch images load to perfection.
To be more specific,
$('.item img').on('load',function(){
//width calculation here
});
Upvotes: 2