Skip to content

Instantly share code, notes, and snippets.

@keenahn
Created July 18, 2012 22:30
Show Gist options
  • Save keenahn/3139373 to your computer and use it in GitHub Desktop.
Save keenahn/3139373 to your computer and use it in GitHub Desktop.
Create a youtube iframe using jQuery
jQuery ->
window.youtube_iframe = (video_id, args) ->
default_options = {
width: 853
height: 480
autoplay: 0
rel: 0
class: "youtube-video"
frameborder: "0"
allowfullscreen: true
}
options = $.extend(false, default_options, args)
options.src = "http://www.youtube.com/embed/" + video_id + "?rel=" + options.rel + "&autoplay=" + options.autoplay
ret = $(document.createElement "iframe")
ret.attr options
return ret
@keenahn
Copy link
Author

keenahn commented Jul 18, 2012

Return value is ready to be appended or prepended to your jQuery objects.

@keenahn
Copy link
Author

keenahn commented Jul 18, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment