javascript - Manipulating the html elements inside the view which is inside the src of iframe -


I have an IFrame view and I'm providing another view in src for iframe now The data that is getting the ID is present and is present in the second view provided inside the source of IFRAME. Please use an example

example:

  Var frame = document.getElementsByTagName ("iframe") [0] .contentDocument; // first iframe in page // or var frame = window.frames ["myframe"]. Document; // If your frame is named "myframe" / or var frame = document.getElementById ('myframe'). ContentWindow.document; // If the id is "myframe" in your frame then  

Then you can access your H2 tag from within the iframe:

  Var h2 = frame.getElementsByTagName ("h2") [0];  

jQuery solution:

  var frame = $ ("selector"). material (); // Where the selector is "# myframeID" or ".from myframeClass", etc ... var h2 = frame.find ("h2");  

Comments