2015-11-04 48 views
0

我想要显示图像(300x169),并且当用户单击图像时,它将被替换为相同尺寸的iframe(位于同一位置)。单击时用iframe替换的图像

+1

这么是规则,你应该告诉你已经尝试了什么。不要简单地问一个问题的解决方案,而不要显示你已经做了一些尝试自己弄明白的问题。 – AgapwIesu

+0

使用onClick事件 – LearningProcess

回答

0

我只告诉你jQuery的方法:

<html> 
    <head> 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
    </head> 
    <body> 
     <p>Some html content</p> 
     <div id='holder'><img id='myImg' width='300' height='169' src="noimage.png"></div> 
     <p>Some other html content</p> 
    </body> 
    <script> 
     $('#myImg').click(function() { 
      $('#myImg').remove(); 
      $('<iframe/>') 
       .attr('id', 'iframeId') 
       .attr('src', 'http://someurl') 
       .appendTo("#holder") 
     }); 
    </script> 
</html 

>