I am trying to select an image by the CSS that is automatically applied through a CMS to that image and then add a class. Here is my script:
$(document).ready(function() {
if ($('.pageBody p img').css('float') === 'right') {
$('.pageBody p img').addClass('float-right');
}
});
That script works just fine with an image that has float: right applied. There is another image that has float: left applied. The problem is, if I switch "right" to "left" in the script than it wont' work. For example, if I have an image set to float: left and use this script than it doesn't work:
$(document).ready(function() {
if ($('.pageBody p img').css('float') === 'left') {
$('.pageBody p img').addClass('float-left');
}
});
right, and notleft, are you sure it actually has that style applied.console.log($('.pageBody p img').css('float')), it should give you enough information.