I have this structure, and i want to remove test2
class from div
iframe1 -> iframe2 -> <div class="test1 test2">.... </div>
I am able to access iframe2 but I am not able to find above div in second iframe.
here what I have tried
document.querySelectorAll('iframe').forEach(item => {
var y = item.contentDocument.body.getElementsByTagName("iframe");
setTimeout(() => {
y[0].style.width = '100vw';
$(y[0]).contents().find(".test2").removeClass('.test2')
}, [500])
})
y[0].style.width = '100vw';
this is working. but I am not able to find div with test2
class
console.log(y[0]) is iframe as expected.
y[0].contentDocument
is null
if anyone can help me with this. Thanks in advance
Also in some answers I found that we can't change contents of iframe if it is of cross origin. but here I have same origin.
I just want some css changes either i need to remove test2 class or override it.