javascript - jQuery Not Executing Function As Expected -
im sure have problems code. im not sure how mix raw javascript jquery. here relevant code in js file:
$(document).ready(function() { $('#show-video').click(function(event) { jquery('.player-hold').slidedown("slow"); $('#book').slidedown('slow', function() { playvideo(); }); jquery('.features').slideup("slow"); }); }); function onplayerstatechange(newstate) { if(newstate == 0) { jquery('.player-hold').slideup("slow"); jquery('.features').slidedown("slow"); } } function playvideo() { if (ytplayer) { ytplayer.playvideo(); } } function onyoutubeplayerready(playerid) { ytplayer = document.getelementbyid("ytplayer"); ytplayer.addeventlistener("onstatechange", "onplayerstatechange"); ytplayer.setplaybackquality("highres"); ytplayer.cuevideobyid("pota2ftmdwk"); }
basically have div link view video. when link clicked video (previously display none) shown , div containing link hidden. works fine. last part once video ends video slidesaway , div container comes back, works. problem is, once video shown want execute play video. not working.
im sure easy fix/nooby mistake.
ps. if remove jquery , add function playvideo(); on click anchor, plays video expected loses sliding functionality.
you using odd mix of $(
, jquery(
in code. should choose 1 or other. $(
preferred unless conflicts library. in case of conflict, jquery(
, use noconflict().
Comments
Post a Comment