Reputation: 7121
I have this div:
<div class="main_mark">
<img src="/assets/welcome_main.png" alt="main" class="main_mark_image" />
</div>
I want the next thing: when the user click the image, this div will changed to:
<div class="main_mark">
<embed width="420" height="345" src="http://www.youtube.com/v/XjR-4lbK1mI" type="application/x-shockwave-flash">
</embed>
</div>
so in my javascript, I have tried to do something like:
$(".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>";
});
but it doesn't change anything..
any help aapreciated!
Upvotes: 0
Views: 630
Reputation: 410
use a combo of both @sdespont and @kmd97
$(".main_mark_image").click(function () {
// Changed selector to class
$(".main_mark").html("<embed width=420 height=345 src=http://www.youtube.com/v/XjR-4lbK1mI type=application/x-shockwave-flash></embed>");
});
Upvotes: 1
Reputation: 23344
Try:
$(".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>";
});
Upvotes: 1
Reputation: 14025
Use html
function : 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>");
});
Upvotes: 1
Reputation: 3015
$(".main_mark").html("Your code")
instead of $("#main_mark").innerHTML
Upvotes: 1