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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

querySelectorAll選擇基于css

querySelectorAll選擇基于css

慕運維8079593 2021-12-23 10:17:52
這是我遇到的問題的簡單表示。當您單擊按鈕時,所有黑色 div 都應變?yōu)楹谏?。但是?css 樣式的大的沒有。有任何想法嗎?多謝。var v;function link() {  v = document.querySelectorAll('[style*="background:black;"]');  v.forEach(function(value) {    value.style.backgroundColor = "red";  });}.box1 {  background-color: black;  height: 200px;  width: 200px;  border: 2px solid green;  font-size: 25px;  color: white;}<html><head>  <link rel="stylesheet" href="filter.css" /></head><body>  <div style="background:black; height:100px; width:100px;" id="div1"></div>  <div style="background:blue; height:100px; width:100px;"></div>  <div style="background:black; height:100px; width:100px;"></div>  <div class="box1"> css styled box</div>  <button onclick="link()" style="height:20px; width:50px;">Click </button></body></html>
查看完整描述

1 回答

?
滄海一幻覺

TA貢獻1824條經(jīng)驗 獲得超5個贊

試試這個


var v;

function link(){

  v=document.querySelectorAll('[style*="background:black;"]');

  v.forEach(function(value){

    value.style.backgroundColor = "red";

  });

}

.box1{

  height:200px;

  width:200px;

  border:2px solid green;

    font-size:25px;

    color:white;

}

<html>

<head>

<link rel="stylesheet" href="filter.css" />

</head>

<body>


<div style="background:black; height:100px; width:100px;" id="div1"></div>

<div style="background:blue; height:100px; width:100px;"></div>

<div style="background:black; height:100px; width:100px;"></div>

<div class="box1" style="background:black;"> css styled box</div>

<button onclick="link()" style="height:20px; width:50px;">Click </button>


</body>

</html>


查看完整回答
反對 回復 2021-12-23
  • 1 回答
  • 0 關注
  • 167 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號