請幫我看看這段代碼為什么沒有用 點(diǎn)擊不能切換 只顯示紅色
?<div class="change">
? ? ? ? 點(diǎn)我變化
? ? </div>
<script type="text/javascript">
? ?
? ? ? ? $(".change").click(function(){
? ? ? ? ? ? if($(this).css("color")=="red"){
? ? ? ? ? ? ? ? $(this).css("color","yellow");
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ?$(this).css("color","red");
? ? ? ? ? ? }
? ? ? ? })
</script>
2017-10-06
比較的時(shí)候把顏色轉(zhuǎn)換為rgb了
把條件里的red換成rgb(255, 0, 0)就可以了 ?注意0前面要加空格