Button Click Example

Creates an input button and assigns a click event to it.

by Ryan Brackett

HTML

<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css">
<html>

  <body>

    <ul class="video-list">
      <li>Pre-Conception Counseling</li>
      <li><a href="https://www.youtube.com/watch?v=zjRMg_yETo0" target="_blank">Family Planning Counseling and Birth Control Management</a></li>
      <li><a href="https://www.youtube.com/watch?v=gn6y1XDvWy4" target="_blank">Infertility Workup and Management</a></li>
      <li>IUD (Including Mirena, Paragard, Skyla and Nexplanon)</li>
    </ul>

  </body>

</html>

JavaScript

$('.video-list a').click(function() {
  var video_source = $(this).attr("href");
  var video_id = video_source.match(/v=(.{11})/)[1]
 $('.video-list a').removeClass("active");
 $(this).addClass("active").append('<iframe src="https://www.youtube.com/embed/' + video_id + '" frameborder="0" allowfullscreen></iframe>');
  return false;
});