I am looping through a set of images, and then setting their height to match a variable. The following code is working just fine with Firefox, however is unresponsive in Android's browser. Thoughts?
var x = 100;
count_li = 5;
for (var i = count_li - 1; i >= 0; i -= 1) {
var carousel_img = '#carousel_img_' + [i];
$(carousel_img).css('height', x);
}
Where I have a set of 5 images that might look like this:
<img id="carousel_img_0" src="img_0.jpg"/>
<img id="carousel_img_1" src="img_1.jpg"/>
etc...
Here is a similar post for reference, but I'm not finding what I need in it.
A secondary, directly connected issue is that this code is having the exact issue:
var img_w = $(carousel_img).width();
Presumably it too needs a 'px' reference, but I'm unaware of the syntax.
Solutions ----------------------------------------------------------
As stated by Matt, this
$(carousel_img).css('height', x);
needed to have a 'px' added to the end, as seen below:
$(carousel_img).css('height', x + 'px');