how to get all videos duration before or without playing the video using jquery or javaScript : Hello I have problem in my code to getting duration of all videos. error showing me undefined below my code please help me anyone for that.

        $("video").each(function(){
    var duration = $(this).attr('duration');
    alert(duration);
    });

its giving me undefined alert please tell me where i doing wrong i want all videos duration before playing video Thanks hopes help