html限制仅有一个音/视频可播放

embedded/2024/9/24 10:19:35/

html_0">html限制仅有一个音/视频可播放

请添加图片描述

/** 多个音频仅能播放一个 */
function audiosPlay() {const audios = document.getElementsByTagName('audio');const videos = document.getElementsByTagName('video');function pauseAll() {var self = this;[].forEach.call(audios, function (i) {if (i !== self) i.pause();});[].forEach.call(videos, function (i) {i.pause();});}[].forEach.call(audios, function (i) {i.addEventListener('play', pauseAll.bind(i));});
}/** 多个视频仅能播放一个 */
function videosPlay() {const audios = document.getElementsByTagName('audio');const videos = document.getElementsByTagName('video');function pauseAll() {var self = this;[].forEach.call(videos, function (i) {if (i !== self) i.pause();});[].forEach.call(audios, function (i) {i.pause();});}[].forEach.call(videos, function (i) {i.addEventListener('play', pauseAll.bind(i));});
}

http://www.ppmy.cn/embedded/112779.html

相关文章

前端深拷贝

什么是 structuredClone()? structuredClone() 是 2022 年引入的全局函数,支持深度克隆 JavaScript 对象。与 JSON.stringify() 和 JSON.parse() 等传统方法不同,它们难以处理复杂的结构和循环引用,而 structuredClone() 可以毫不…

GVIM常用命令

Gvim常用命令 1.操作文件 1.1 gvim比较两个文件的不同 gvim -d file1 file2 2.操作文件内容 2.1全文替换 :1,$s/旧字符/新字符/g 2.2多行插入 步骤一:ctrlv进入visual模式 步骤二:选中要插入的行 步骤三:ctrlI进入insert模式 步骤…

Unity中InputField一些属性的理解

先看代码: using UnityEngine; using UnityEngine.UI;public class TestInput : MonoBehaviour {[SerializeField]InputField inputField;void Start(){Debug.Log(inputField.text);Debug.Log(inputField.text.Length);Debug.Log(inputField.preferredWidth);Debug…

HTML/CSS/JS学习笔记 Day4(CSS--C1 选择器声明)

跟着该视频学习,记录笔记:【黑马程序员pink老师前端入门教程,零基础必看的h5(html5)css3移动端前端视频教程】https://www.bilibili.com/video/BV14J4114768?p12&vd_source04ee94ad3f2168d7d5252c857a2bf358 Day4 内容梳理:…

Golang | Leetcode Golang题解之第400题第N位数字

题目: 题解: func findNthDigit(n int) int {d : 1for count : 9; n > d*count; count * 10 {n - d * countd}index : n - 1start : int(math.Pow10(d - 1))num : start index/ddigitIndex : index % dreturn num / int(math.Pow10(d-digitIndex-1)…

WPS如何删除表格下的空白页

WPS Office(12.1.0.17827) ① 鼠标右键,选择段落 ② 行距:固定值;设置值:1磅;取消勾选,确定即可~

c++题目_洛谷 / 题目详情 P1012 [NOIP1998 提高组] 拼数

# [NOIP1998 提高组] 拼数 ## 题目描述 设有 $n$ 个正整数 $a_1 \dots a_n$,将它们联接成一排,相邻数字首尾相接,组成一个最大的整数。 ## 输入格式 第一行有一个整数,表示数字个数 $n$。 第二行有 $n$ 个整数,表…

DroidBot-GPT: GPT-powered UI Automation for Android论文学习

本文介绍了DroidBot GPT,这是一种利用类似GPT的大型语言模型(LLM)自动化与Android移动应用程序交互的工具。给定所需任务的自然语言描述,DroidBot GPT可以自动生成并执行导航应用程序以完成任务的操作。它的工作原理是将应用程序G…