Hover / replaceWith woes. (I'm new, this should be simple)
Howdy!
Quick question...
I've got a quick and dirty little jQuery script set up so that when I hover over a div (#meatHome), a smaller div with a play button pops up (#playVideo). When you hit play, a div with a youtube embed comes up and plays (#promoVideo). Everything works, save for the fact that once the video comes up, I don't want the play button to come up anymore when I hover over it. Here's the code:
- $(function() {
- // Hide the play button and the video from the start
- $("#playVideo").hide();
- $("#promoVideo").hide();
-
- // On hover over the main div, show the play button
- $("#meatHome").hover(function(){
- $("#playVideo").show();
- },function(){
- $("#playVideo").hide();
- });
-
- // When the play button is pressed, show the video player
- $("#playVideo>h1>a").click(function(){
- $("#playVideo").hide();
- $("#promoVideo").show();
- });
- });
Now, I have also tried using this for the function on lines 15 thru 18.
- $("#playVideo>h1>a").click(function(){
- $("#playVideo").replaceWith($("#promoVideo"));
- });
Which succesfully hides the #playVideo div permanently but fails to show the video div. If I swap out ($("#promoVideo")) with a simple string of text, it appears to work just fine. Can anybody shed some light on my plight?
P.S. If you need the html code, here it is as well.
- <div class="grid_7 suffix_3" id="meatHome">
- <div id="playVideo">
- <h1><a href="#">Play!</a></h1>
- </div>
- <div id="promoVideo">
- <object width="515" height="315"><param name="movie" value="http://www.youtube.com/v/CqSjbj12iLs&hl=en_US&fs=1&hd=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CqSjbj12iLs&hl=en_US&fs=1&hd=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="515" height="315"></embed></object>
- </div>
- </div>
Thanks in advance!!