<div> <input type="url" placeholder="Enter Youtube video URL"> <a href="#" onClick="videoViews()">GO</a> </div> <div class="videoembed"></div> <div class="views"></div> -------------------------------------------------- function videoViews() { var rex = /[a-zA-Z0-9\-\_]{11}/, videoUrl = $('input').val() === '' ? alert('Enter a valid Url'):$('input').val(), videoId = videoUrl.match(rex), jsonUrl = 'http://gdata.youtube.com/feeds/api/videos/' + videoId + '?v=2&alt=json', embedUrl = '//www.youtube.com/embed/' + videoId, embedCode = '<iframe width="350" height="197" src="' + embedUrl + '" frameborder="0" allowfullscreen></iframe>' ...