Set jQuery data() on an iFrame body tag and retrieve it from inside the iFrame - Javascript jQuery

Javascript examples for jQuery:iframe

Description

Set jQuery data() on an iFrame body tag and retrieve it from inside the iFrame

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 </head> //  w w w  .  j a  v a  2 s.c o  m
 <body> 
  <iframe src="http://jsbin.com/"></iframe> 
  <script>
$(function() {
   var scope = $('iframe')[0].contentWindow.document;
   $('body', scope).data('id', 'some id');
   console.log($('body', scope).data('id'));
});

      </script>  
 </body>
</html>

Related Tutorials