On the page using the script (widget) displays iframe <iframe id="form_iframe" и т.д. . How can I load a page using javascript to transfer it higher to another element in a .content block? This is how the problem is not solved:

 $("#form_iframe").prependTo(".content"); 

Thank you

  • iframe of your domain or someone else's? Actually, the accuracy of the answer may depend on it - Andrew ProjectSoft
  • Please describe in more detail the problem you are trying to solve. - Dmitry Miroshnichenko

3 answers 3

jQuery('#form_iframe').clone().prependTo('.content')

  • Dmitry, I greet you! No, this is not the way to solve the problem - LADYX

 function move1() { $("#test").prependTo(".content1"); } function move2() { $("#test").prependTo(".content2"); } move1(); 
 .content { border: 1px solid black; width: 200px; height: 50px; } .content1 { background-color: lightblue; } .content2 { background-color: lightgreen; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="content content1"></div> <div class="content content2"></div> <button onclick="move1()">Click 1</button> <button onclick="move2()">Click 2</button> <br> <iframe id="test" style="width:130px;height:30px;" src="about:blank"></iframe> 

  • Igor, I greet you! No, it is not necessary when the button is pressed, but it is necessary that already when the page is loaded, the iframe is moved to another element in the '.content' block - LADYX
  • @LADYX Added line move1(); . - Igor

If you want to transfer:

 $('.content').append($('#form_iframe')); 

If you clone:

 $('.content').append($('#form_iframe').clone());