Thursday, 15 September 2011

javascript - How to Active Dynamic - or Video Tab? -



javascript - How to Active Dynamic <li> or Video Tab? -

i retrieving videos youtube playlist , loads carousal.

now, want active dynamic < li >. when click of 1 < li > or video (which within < li >. suppose active.

var playlisturl = 'http://gdata.youtube.com/feeds/api/playlists/'+nplaylistid+'?v=2&alt=json&callback=?'; var videourl= 'http://www.youtube.com/watch?v='; $.getjson(playlisturl, function(data) { var list_data=""; $.each(data.feed.entry, function(i, item) { var feedtitle = item.title.$t; var feedurl = item.link[1].href; var fragments = feedurl.split("/"); var videoid = fragments[fragments.length - 2]; var url = videourl + videoid; var thumb = "http://img.youtube.com/vi/"+ videoid +"/default.jpg"; list_data += '<li><a href= "#" title="'+ feedtitle +'" onclick=show_yt_vid("'+videoid+'");><img src="'+ thumb +'" /></a></li>'; });

demo link:- http://jsfiddle.net/4hhag/

screen shot (how want) :- https://docs.google.com/file/d/0b1eurqdt0liewueydnviuth6nwm/edit?usp=sharing

thanx in advance !!!!!! :)

what suggest is: add together class tags in loop

list_data += '<li><a class="vids" href= "#" title="'+ feedtitle +'" onclick=show_yt_vid("'+videoid+'");><img src="'+ thumb +'" /></a></li>';

and utilize jquery add together class element clicked

$(document).on('click', '.vids', function() { $('.vids').removeclass('active'); $(this).addclass('active'); });

here's demo: http://jsfiddle.net/4hhag/1/ add together background class 'active' in css image want

javascript jquery youtube youtube-api

No comments:

Post a Comment