简体   繁体   English

Onclick删除/删除图像

[英]Onclick Remove/delete image

I need to load an .swf file after we click on an image 单击图像后,我需要加载.swf文件

The .swf file loads successfully after we click on the image,but it loads the .swf below the image.I need to replace the img with .swf(in short,hide the img). 单击图片后,.swf文件成功加载,但是将图片下的.swf加载。我需要将.swf替换为img(简而言之,隐藏img)。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script type="text/javascript">

function loadSWF(url){
    swfobject.embedSWF(url, "flashcontent", "550", "400", "9");
}
document.getElementById('iii').style.display = 'none';

</script>

<p><a href="http://www.leconcombre.com/stock/coccyminimini1.swf" onclick="loadSWF(this.href); return false;">


<div id="iii" class="iii">
<img id="my_image17" border="0" src="http://4.bp.blogspot.com/-7Ij8T9BvULw/VJWltsHNmhI/AAAAAAAANDI/a76wpzm_a-E/s1600/world%2Bmap%2Bcolor_1.jpg" />
</div>

</a></p>

<div id="flashcontent"></div>

I need to hide/remove the class/id "iii" (within which the img tag lies).However the code doesn't seem to work only with respect to hiding/removing of img. 我需要隐藏/删除class / id“ iii”(img标记位于其中)。但是,该代码似乎仅对img的隐藏/删除无效。 Any tips? 有小费吗?

Looks like ... 看起来像 ...

function loadSWF(url){
    swfobject.embedSWF(url, "flashcontent", "550", "400", "9");
    document.getElementById('iii').style.display = 'none';
}

... the hide should occur when the load does. ...负载发生时,皮革应该出现。

I think this is what you're looking for. 我认为这就是您要寻找的。

I made a js fiddle for you. 我为您制作了一个js小提琴。 http://jsfiddle.net/q7a96h14/1/ http://jsfiddle.net/q7a96h14/1/

html html

<div id="iii" class="iii">
  <img id="my_image17" border="0" src="http://4.bp.blogspot.com/-7Ij8T9BvULw/VJWltsHNmhI/AAAAAAAANDI/a76wpzm_a-E/s1600/world%2Bmap%2Bcolor_1.jpg" /> 
</div>

js js

$(function(){
  var $img       = $("#my_image17")
    , $container = $("#iii");
  $img.on("click", function() {
    $img.remove();
    $container.html("<embed src='http://www.leconcombre.com/stock/coccyminimini1.swf' width='550'  height='400'/>");
    $container.removeClass().removeAttr("id");
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM