使用 .load 和 jQuery 在 DIV 中加载 HTML 页面

问题描述 投票:0回答:3
javascript jquery html
3个回答
1
投票

你的 html 和 JS 应该像这样分开:

<div id="myModal" class="reveal-modal" title="El Farol" data-animation="fade">
</div>

 <script>
     $(document).ready(function() {
         $('#myModal').load("/app_dev.php/register", function() {
              $('#myModal').append( '<a class="close-reveal-modal">&#215;</a>' );
         });
     });
 </script>

1
投票

试试这个:

我将链接插入了

a href
标签而不是脚本...这样替换链接会更容易。

HTML:

<div id="myModal" class="reveal-modal" title="El Farol" data-animation="fade">
<a class="close-reveal-modal" href="http://devserver/app_dev.php/register">Page 1</a>

JQuery:

$(document).ready(function(){
  $('a').click(function(e){
     e.preventDefault();
     $("#myModal").load($(this).attr('href'));
  });
});

0
投票
<div id="calc">
            <object class="calculator" type="text/html" data="calc53.html"  height="550px" width="250px"style="overflow-y:visible">
            </object>
            <!--<embed src="calc53.html" height="550px">-->
    </div>

其中任何一项都应该有效。 W3学校......

© www.soinside.com 2019 - 2024. All rights reserved.