Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add class for interior iframe html elements using Jquery

Tags:

jquery

iframe

Hi friends I have tried to add class for iframe html elements using jquery but I can't, I dont know how. could you explain how can this be possibly done. I tried to add class for iframe using query

$("iframe").addClass("myClass");

it worked for iframe but I want to add the class inside the iframe elements in jquery could you help me in this to solve it.

like image 572
Sri Avatar asked Aug 15 '14 10:08

Sri


1 Answers

You need to use the function contents() to get the document inside the iframe, and then you have to use the function find() to select the element inside the iframe.

$("iframe").contents().find("#element").addClass("myClass");
like image 122
Khalid Avatar answered Sep 22 '22 17:09

Khalid