I want to set an object's css margin-left property to 1000 if it's lower than 0, but it isn't working as I want.
This is the code I'm using:
$(".slide").each(function(a, b) {
m=$(this).css("margin-Left");
if (m <= "0px") {
console.log($(this).css("margin-left"));
$(this).css({"margin-left": width + "px"});
}
});
The issue here is that
.css('margin-left')will return you a string. Change your code in the following way: