简体   繁体   中英

hide iframe div within it

so i have this HTML for example:

<!DOCTYPE html>
<html>
<head>
</head>
<body>

 <div>how are you</div>
 <p>whatttt</p>
<div id="main">
<div id="test">
  div content
<br>
<table class="table">
  <thead> </thead>
    <tr>
       <th>
         some header
       </th>
    </tr>
    <tr>
       <td> cell </td>
    </tr>
  </table>  
</div>  
  </div>
</body>
</html>

so if i want to load this with i frame but load only the div class="main" it will be like this:

<iframe class="test" src="testing.html" onload="$('body>*',this.contentWindow.document).not('#main').hide();"></iframe>

what if i want to show only for example : the div id="test" or the table class="table" that are in the din class="main" how can i go deeper to those divs in that main div?

Thanks in advance guys!

Try this,

For div with id = test within div id = main

this.contentWindow.document).not('#main #test').hide();

<iframe class="test" src="testing.html" onload="$('body>*',this.contentWindow.document).not('#main #test').hide();"></iframe>

For div with class = table within div id = main

this.contentWindow.document).not('#main .table').hide();

<iframe class="test" src="testing.html" onload="$('body>*',this.contentWindow.document).not('#main .table').hide();"></iframe>

I don't think you can modify the content inside an iframe. You can try loading it into a div instead.

$('.test').load('testing.html #main');

Replace

<iframe class="test"> with <div class="test">

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM