How Do I Dynamically Add &autoplay=1 To Youtube Embed Codes? December 07, 2022 Post a Comment This is an examples of the youtube embed code on my site: ).val(function(i, oldVal) { return oldVal + (oldVal.indexOf('?') ? '&autoplay=1' : '?autoplay=1'); }); $('embed').prop('src', function(i, oldSrc) { return oldSrc + (oldSrc.indexOf('?') ? '&autoplay=1' : '?autoplay=1'); } Copy You might prefer to do a slightly more specific selector, for instance $('embed[src^="http://www.youtube.com/"]') or perhaps $('object param[name="movie"]') -- it depends on what your page contains elsewhere... See the API reference: attribute-equals selector val prop Solution 2: To play a YouTube movie by JavaScript, you'll better use the JavaScript Player API: http://code.google.com/intl/nl/apis/youtube/js_api_reference.html (Yes I know this is not precisely the answer to the OP's question).Baca JugaHow Do I Dynamically Add &autoplay=1 To Youtube Embed Codes?Video Gets Hidden Via Javascript But Already Starts To Play (autplay-mode) Even It's Not Visible?Is There Anyway That I Can Put An Movie Clip On Mouse-over To Autoplay My Movie? Share You may like these postsEmbed Youtube Videos That Play In Fullscreen AutomaticallyGet Youtube Playlist IndexHidden Youtube Player Loses Its MethodsSocial Media Sites Preventing Other Sites Displaying Their Pages In An Iframe Post a Comment for "How Do I Dynamically Add &autoplay=1 To Youtube Embed Codes?"