Grow your CSS skills. Land your dream job.

Last updated on:

Get YouTube Key from a Link

// Example link:
// <a id="myLink" href="http://www.youtube.com/watch?v=cyRqR56aCKc&feature=PlayList&p=00000000000&index=0&playnext=1">Youtube link</a>

var youtubeLink = document.getElementById('myLink').href;
var youtubeVideoKey = youtubeLink.substr(youtubeLink.lastIndexOf("v=") + 2, 11);

// youtubeVideoKey will return "cyRqR56aCKc"

Comments

  1. Permalink to comment#

    Amazingly timely! I was just trying to work this out myself when this showed up in my RSS feed; thanks!

  2. Permalink to comment#

    I’ve been exploring for a little bit for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I finally stumbled upon this web site. Reading this information So i’m satisfied to express that I’ve an incredibly excellent uncanny feeling I found out exactly what I needed. I such a lot indisputably will make sure to do not forget this website and give it a glance on a continuing basis.

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
    ``` 
    <div>
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
    </div>
    ```
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".