Get URL of thumbnail for youtube videos version 3

Hi
 I'm trying to get the video url of the thumbnail, so when you click on the thumbnail the video will play.

I can get the thumbnail to display but can't figure out how to get the URL

Here is what I have so far.

Thanks for the help!
<script>
    function keyWordsearch(){
            gapi.client.setApiKey('AIzaSyB7oqNYxEGnskHEpKHSCbIH_-VI4_sJkzg');
            gapi.client.load('youtube', 'v3', function() {
                    makeRequest();
            });
    }
    function makeRequest() {
            var q = $('#query').val();
            var request = gapi.client.youtube.search.list({
                    q: q,
                    part: 'snippet', 
                    maxResults: 10,
                    
            });
            request.execute(function(response) {                                                                                    
                    $('#results').empty()
                    var srchItems = response.result.items;                      
                    $.each(srchItems, function(index, item) {
                    vidTitle = item.snippet.title; 
                    videoId  =  item.snippet.videoId
                    vidThumburl =  item.snippet.thumbnails.default.url;                 
                    vidThumbimg = '<pre><a href="https://www.youtube.com/watch?v='+vidThumburl+'"><img id="thumb" src="'+vidThumburl+'" alt="'+vidTitle+'" style="width:204px;height:128px"></a></pre>';                   

                    $('#results').append('<pre>' + videoId + vidThumbimg + '</pre>');                      
            })  
        })  
    }
  </script> 
<script src="https://apis.google.com/js/client.js?onload=googleApiClientReady"> </script>



 <div id="buttons">
   <label> <input id="query" value='cats' type="text"/><button id="search-button"  onclick="keyWordsearch()">Search</button></label>    
   <div id="container">
     <h1>Search Results</h1>
     <ul id="results"></ul>
   </div>  

Open in new window

smfmetro10Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You can get the URL like this

var url = $('#results a');

Open in new window


Is that what you were asking?
Julian HansenCommented:
Ignore previous.

To expand ...

$(function() {
   $('#result a').click(function(e) {
        e.preventDefault();
        var url = $(this).attr('href');
   });
});

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smfmetro10Author Commented:
Thanks!
Julian HansenCommented:
You are welcome - good luck with your project.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.