How Do I Dynamically Add &autoplay=1 To Youtube Embed Codes? March 23, 2024 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'); } CopyYou 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 selectorvalpropSolution 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 JugaUse 'noty' Js Library In Rails 5How To Work With Multiple Css Properties?Use 'noty' Js Library In Rails 5 Share You may like these postsShow Sum Of Dynamic Radio Input Element And It Should Also Show When Click On Another Radio Input ElementLoop Through List Of Maps To Filter Map Key-values Using JsChange Color Of Specific Text Within Html Tags Using JavascriptChange Selected Value Of Kendo Ui Dropdownlist Post a Comment for "How Do I Dynamically Add &autoplay=1 To Youtube Embed Codes?"