I'm facing an issue with an if statement in jQuery that is supposed to resize images displayed in the DOM. The logic seems correct as it alerts the new width value, but for some reason, this value isn't being applied to the CSS line below. Any thoughts on what might be causing this problem?
Here's a snippet of the jQuery code:
$('span.i_contact').each(function() {
var imgWidth = parseInt($(this).data('image-width'));
console.log(imgWidth)
if (imgWidth < 600) {
var newWidth = ((imgWidth / 600) * 300);
alert(newWidth);
$(this).css({
"width":newWidth
});
}
// Additional logic here...
});
$("span.o_contact").each(function() {
var imgWidth = parseInt($(this).data('image-width'));
console.log(imgWidth)
if (imgWidth < 600) {
var newWidth = ((imgWidth / 600) * 300);
alert(newWidth);
$(this).css({
"width":newWidth
});
}
// Additional logic here...
});
This is how the images are generated using ERB:
<% n = steps.index(step) %>
<h2 style="margin-left:20px;"> Step <%= n + 1%></h2>
// More ERB code here...