简体   繁体   English

如何检测视频标签中是否有源标签

[英]How can I detect if there is a source tag inside the video tag

when I load a video I have this video tag:当我加载视频时,我有这个视频标签:

<video data-required="video" id="video-upload-preview" controls="">
    <source src="blob:https://localhost:4000/cbbd8fac-6a37-4294-a86c-f32cedb6fb79">
</video>

When I haven't loaded a video the video tag is like:当我没有加载视频时,视频标签就像:

<video data-required="video" id="video-upload-preview" controls=""></video>

How can I detect if there is a source tag inside the video or not using JavaScript?如何检测视频中是否source标签或未使用 JavaScript?

const source = document.querySelector('video source')
 if(source){
    console.log(source)
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM