第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

修改視頻元素的outerHTML而不破壞視頻

修改視頻元素的outerHTML而不破壞視頻

慕哥9229398 2023-10-10 15:01:24
我正在開(kāi)發(fā)一個(gè) Firefox 擴(kuò)展,用于向視頻元素添加疊加層。我使用https://www.w3schools.com/html/mov_bbb.mp4作為一個(gè)單獨(dú)的示例進(jìn)行測(cè)試。但是,如果我說(shuō):$0.outerHTML = $0.outerHTML;在控制臺(tái)中,視頻停止播放并消失,只留下盒子陰影。請(qǐng)注意,我在常規(guī)網(wǎng)頁(yè)上沒(méi)有遇到此行為。我在 Chrome 中也沒(méi)有遇到這種行為。我想添加我的 UI 元素,但我找不到解決方法。
查看完整描述

1 回答

?
慕絲7291255

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

目前尚不清楚您想對(duì)視頻本身做什么。但是,我首先會(huì)嘗試擺脫 CSS。如果您確實(shí)想撕下視頻,然后將其包裝在您自己的 HTML 中并將其放回原來(lái)的位置,您可以這樣做:


// Get reference to the video element

const videoElement = document.getElementsByTagName('video')[0];

// Clone the element

const videoClone = videoElement.cloneNode(true);

// Create your new container

const videoContainer = document.createElement('div');

// Do what you want with the new container

const someHeading = document.createElement('h1');

someHeading.innerText = 'This is a video';

// Append stuff to the new container

videoContainer.append(someHeading);

// Append the cloned video to the new container

videoContainer.append(videoClone);

// Remove the old video

videoElement.remove();

// Append your new video container with cloned video

document.body.append(videoContainer);

<video width="320" height="240" controls>

  <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">

  Your browser does not support the video tag.

</video>

設(shè)置outerHTML只會(huì)覆蓋 HTML。如果您想看到差異,您可以嘗試 和 的設(shè)置innerHTML,outerHTML但就您而言,結(jié)果可能相同。



查看完整回答
反對(duì) 回復(fù) 2023-10-10
  • 1 回答
  • 0 關(guān)注
  • 98 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)