我有这个div:
<div class="main_mark">
<img src="/assets/welcome_main.png" alt="main" class="main_mark_image" />
</div>
我想要下一件事:当用户单击图像时,此 div 将更改为:
<div class="main_mark">
<embed width="420" height="345" src="http://www.youtube.com/v/XjR-4lbK1mI" type="application/x-shockwave-flash">
</embed>
</div>
所以在我的 JavaScript 中,我尝试做类似的事情:
$(".main_mark_image").click(function () {
$("#main_mark").innerHTML = "<embed width=420 height=345 src=http://www.youtube.com/v/XjR-4lbK1mI type=application/x-shockwave-flash></embed>";
});
但这并没有改变任何东西..
感谢任何帮助!
最佳答案
使用html
函数:http://api.jquery.com/html/
$(".main_mark_image").click(function () {
$("#main_mark").html("<embed width=420 height=345 src=http://www.youtube.com/v/XjR-4lbK1mI type=application/x-shockwave-flash></embed>");
});
关于javascript - 通过单击图像更改 div 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14752156/