- Index HTML has Multiple iframes
- If iframes has xyz class ("I will add/remove a class from Index HTML and I will add a class to anyone of iframe")
- if the iframe has xyz class only in that iframe make h2 tag color red
- if I remove xyz class from iframe make h2 tag normal color
sample HTML file in git : https://github.com/hiraghuak/iframe
My function inside iframe :
<script>
$(function () {
var iframes = parent.document.getElementsByTagName("iframe");
console.log(iframes + ' iframe');
for (var i = 0; i < iframes.length; i++) {
var iframeGetAttribute = iframes[i].getAttribute("class");
console.log(iframeGetAttribute + ' iframe GetAttribute');
if (iframeGetAttribute == 'xyz') {
// ITS ALL WORKING FINE
}
}
});
</script>
Thank you