84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
图片描述
一个p中有两个span 点击是让span的class属性变成class=" btn btn-large btn-primary "另一个 span class=" btn btn-large" [1]加粗文字: /img/bVD9xx
闭关修行中......
<p id="p"> <span style="background-color: red;">第一个span标签</span> <span style="background-color: yellowgreen;">第二个span标签</span> </p>
$("#p span").each(function(i){ if(i==0){ $("p span").on("click",function(){ $(this).addClass("btn btn-large btn-primary"); }) }else{ $("p span").on("click",function(){ $(this).addClass("btn btn-large"); }) } });
<p> <span class="btn btn-large"></span> <span class="btn btn-large"></span> </p>
$(function() { $("span").on("click", function() { $(this).addClass("btn-primary").siblings().removeClass("btn-primary"); }); });
来N个span都没问题
HTML
JS
HTML
JS
来N个span都没问题