javascript - Hide content inside iframe? -


here situation.

i have file called iframe.html. has code in below,

<!doctype html> <html lang="eng">     <head>         <meta charset="utf-8"/>         <title>pluign development</title>          <script src="js/jquery-1.11.0.js" type="text/javascript"></script>     </head>      <body>          <iframe id="abc" src="test.html"></iframe>         <div id="sub">click</div>     </body>      <script src="js/script-22.js" type="text/javascript"></script> </html> 

and have test.html file. has code in below,

<!doctype html> <html lang="eng">     <head>         <meta charset="utf-8"/>         <title>pluign development</title>      </head>      <body>          <div id="red">prasanga karunanayake </div>     </body>   </html> 

here js code have tried,

(function($){       var fire = {         init:function(){             $('#sub')             .on('click', function(){                 $('#red', parent.document).css('display','none');             });         }     };     fire.init();  }(jquery)); 

here situation.

i need hide <div id="red">prasanga karunanayake </div> in test.html file. if click <div id="sub">click</div> hide html content in test.html.

i pretty confused,your appreciated.

you can use .contents() way:

$('#abc').contents().find('#red').hide(); 

another thing is, have wrapped code in closure runs page response gets in browser. might possible code change not work.

instead suggest put dom ready block this:

(function($){      $(function(){ // <---add block here       var fire = {         init:function(){             $('#sub').on('click', function(){                 $('#abc').contents().find('#red').hide();             });         }       };       fire.init();   }); //<----here }(jquery)); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -