I want to access page2.html element containing img tag and update it to the page1.html img tag or replace img of page1.html to page2.html img. Both the files are on same domain so no need to worry about cross domain origin policy.
// Page1.html <body> <img id="someimage1" src="./captcha.asp"></img> <iframe src="page2.html"></iframe> <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript> var getImg = $('iframe').contents().find('#someimage2').html(); $('#someimage1').replaceWith('<img>' getImg '</img>'); </script> </body> I get DOM Update as [object] [Object]
// Page2.html <body> <img id="someimage2" src="./captcha.asp"></img> <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> </body>