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

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

如何在JavaScript中測試CSS顏色

如何在JavaScript中測試CSS顏色

慕哥9229398 2021-04-16 15:11:53
我仍然是javascript和CSS的初學(xué)者,我有一個(gè)書簽心形圖標(biāo),希望根據(jù)該圖標(biāo)是選中還是未選中來顯示警報(bào)。$('button').on('click', function(){  $(this).toggleClass('faved');  if ($(this).hasClass('faved')) {  alert("red");} else {  alert("empty");}  });@yellow: #FFAC33;@gray: #CCC;@red: #E86C6C;button#favorite {  background: transparent;  border: 0;  span {    padding: 20px;    font-size: 70px;    font-weight: normal;    color: @gray;    position: relative;    span {      position: absolute !important;      top: 0;      left: 0;      font-size: 70px;    }  }  }@keyframes favorite {  .favorite;} @-webkit-keyframes favorite {  .favorite;}@keyframes favoriteHollow {  .favoriteHollow;}@-webkit-keyframes favoriteHollow {  .favoriteHollow;}button#heart {  background: transparent;  border: 0;  span {    padding: 20px;    font-size: 70px;    font-weight: normal;    color: @gray;    position: relative;    span {      position: absolute !important;      top: 0;      left: 0;      font-size: 70px;    }  }  &.faved {    span {      -webkit-animation: heart 0.5s;            animation: heart 0.5s;            color: @red;      span {        z-index: 1000;        -webkit-animation: heartHollow 0.5s;              animation: heartHollow 0.5s;            }    }  }}.heart {   {    transform: scale(1);  }  {    transform: scale(1.2);    color: @red;  }   {    transform: scale(1.4);    color: @red;  }   {    transform: scale(1);    color: @red;  }}.heartHollow {   {    transform: scale(1);    opacity: 1;  }   {    transform: scale(1.4);    opacity: 0.5;  }  {    transform: scale(1.6);    opacity: 0.25;  }  {    transform: scale(2);    opacity: 0;    display: none;  }}@keyframes heart {  .heart;} @-webkit-keyframes heart {  .heart;} @keyframes heartHollow {  .heartHollow;}
查看完整描述

1 回答

?
精慕HU

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

用于檢查您必須使用的類.hasClass('your class name')或要檢查背景色if($(this).css('background') == "red")


 $('button').on('click', function(){

      $(this).toggleClass('faved');

      if ($(this).hasClass('faved')) {

          alert("red");

      } else {

          alert("empty");

      }        

    });


查看完整回答
反對(duì) 回復(fù) 2021-04-22
  • 1 回答
  • 0 關(guān)注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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