Im looping through all divs on a specific page and look for a url thats defined by a theme in 'style' attribute. If I find the url I would like to add css to a specific class. I am getting no errors, can someone take a look where I took a wrong turn?
Code:
if (top.location.pathname === '/news/') {
$j("div").each(function() {
if ($j(this).css('background-image') === 'http://daddykate-acc.daddykate.be/wp-content/plugins/js_composer/assets/vc/vc_gitem_image.png') {
$j('.vc_gitem-zone').css('display', 'none');
}
});
}
Little PS: The $j is required to make the code work (WP theme obligation)
EDIT: Ok, so I just used the 'setTimeout' function to make the function run after DOM was loaded. Everything is working fine now, Thank you for all the input !
$j(this).css('background-image') === 'url(http://daddykate-acc.daddykate.be/wp-content/plugins/js_composer/assets/vc/vc_gitem_image.png)'....................................................... check value oftop.location.pathnameand$j(this).css('background-image')console.log($j(this).css('background-image')), what do you get? Seems obvious to debug, right?!