So, if div with class .activity-inner contains an iframe I would like to add a class mleft to the div
my code is:
$('.activity-inner:has(iframe)').addClass('mleft');
but it't not working, mleft class is not added to the div in cases where div with that class has an iframe
I guess there is a simple mistake but I can't find it, I don't have any visible javascript error
thanks
Try it with document ready. It is work for me. Check scripts position on webpage. https://jsfiddle.net/xted1666/1/
$( document ).ready(function() { $('.activity-inner:has(iframe)').addClass('mleft'); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.