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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么我用$("#arron:nth-child(1)").css("color","blue");就不能改變顏色

<!DOCTYPE html>
<html>


<head>
??? <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
??? <title></title>
??? <style>
??? a {
??????
??????? font-size: 30px;
??????? font-weight: 900;
??? }
???
??? div {
??????? width: 200px;
??????? height: 100px;
??????? background-color: yellow;
??????? color: red;
??? }
??? </style>
??? <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>


<body>
??? <h2>get方法</h2>


??? <div id="aaron">
??????? <a>1</a>
??????? <a>2</a>
??????? <a>3</a>
??????? <a>4</a>
??????? <a>5</a>
??? </div>


??? <select id="animation">
??????? <option value="1">get正數(shù)索引參數(shù)</option>
??????? <option value="2">get負(fù)數(shù)索引參數(shù)</option>
??? </select>
??? <input id="exec" type="button" value="點(diǎn)擊執(zhí)行">
??? <script type="text/javascript">
??? $("#exec").click(function() {
??????? $("#arron:nth-child(1)").css("color","blue");
??????? var v = $("#animation").val();
??????? var $aaron = $("#aaron a");


??????? //通過(guò)get找到第二個(gè)a元素,并修改藍(lán)色字體
??????? if (v == "1") {
???????????
??????? } else if (v == "2") {
??????????? //通過(guò)get找到最后一個(gè)a元素,并修改字體顏色
??????????? $aaron.get(-1).style.color = "#8A2BE2"
??????? }
??? });
??? </script>
</body>

</html>


正在回答

5 回答

http://img1.sycdn.imooc.com//5805b76f0001d32506950597.jpg

你的if 條件里都沒(méi)有寫,怎么執(zhí)行。這里給你注釋掉一行,那句不用寫,太麻煩了,而且書寫也不規(guī)范。

0 回復(fù) 有任何疑惑可以回復(fù)我~

$("#aaron>a:nth-child(2)").css("color","blue");

#aaron>a:nth-child(2)

選擇id為aaron元素的所有直接子元素中的a元素,如果其(a元素)是其父元素(div元素)的第二個(gè),則選中

0 回復(fù) 有任何疑惑可以回復(fù)我~

$("#aaron a:nth-child(2)").css("color","#FFF");

0 回復(fù) 有任何疑惑可以回復(fù)我~

沒(méi)看懂


0 回復(fù) 有任何疑惑可以回復(fù)我~

把你那代碼改成 $("div a:nth-child(1)").css("color","blue");就有用了??

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么我用$("#arron:nth-child(1)").css("color","blue");就不能改變顏色

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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