How can I get the html5 video element's width and height

后端 未结 2 1191
忘了有多久
忘了有多久 2020-12-16 15:31

I have a simple html5 video tag:

 
相关标签:
2条回答
  • 2020-12-16 15:58

    Just found out that we can get the video width and height as:

    $("#video").innerHeight();
    $("#video").innerWidth();
    

    These two functions are exposed by jQuery.

    Another reason why jQuery rocks!!!

    0 讨论(0)
  • 2020-12-16 16:08
    $(function () {
    
        $("#video").bind("loadedmetadata", function () {
            var width = this.videoWidth;
            var height = this.videoHeight;
            // ...
    
        });
    
    });
    
    0 讨论(0)
提交回复
热议问题