Html 单击时图像被iframe替换
我想显示一个图像(300x169),当用户单击该图像时,它会被相同尺寸的iframe替换(在相同的位置) 我只向您展示jquery方法:Html 单击时图像被iframe替换,html,image,iframe,Html,Image,Iframe,我想显示一个图像(300x169),当用户单击该图像时,它会被相同尺寸的iframe替换(在相同的位置) 我只向您展示jquery方法: <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body>
<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
一些html内容
其他一些html内容
$('#myImg')。单击(函数(){
$('#myImg')。删除();
$('')
.attr('id','iframeId')
.attr('src','http://someurl')
.附于(“#持有人”)
});
你应该展示你所尝试过的东西,这是很有规则的。不要简单地要求一个问题的解决方案,而不表明你已经做了一些事情来尝试自己解决它。使用onClick事件