日期:2014-05-16  浏览次数:20471 次

addClass加载类,加载的类在创建时为什么一定要写成 #(id名).(class类名); 而直接写 .(class类名)就不能被调用
$(tabtit).find("#numb:first").addClass("bg");


#numb.bg{background-color:White;border-bottom: 1px solid white;}
写成.bg{background-color:White;border-bottom: 1px solid white;}就无法被调用


但同样的$(tab_conbox).find("dl").find("dd:last").addClass("wd");这却能调用
.wd{margin-left:30px;}  


<div id="tabbox">

    <ul class="tabs" id="tabs">
       <li id="numb"><a   href="#">1</a></li>
       <li id="numb"><a   href="#">2</a></li>
       <li id="numb"><a   href="#">3</a></li>
       <li id="numb"><a   href="#">4</a></li>
       <li id="word"><a   href="#">实惠推荐</a></li>
    </ul>
    <ul class="tab_conbox" id="tab_conbox">
        <li class="tab_con">
            <dl  id="box1">
            <dd ></dd>
            <dd ><a>dddddddddddddddd</a></dd>
            </dl>
     </ul>
            </div>
addClassweb?类名? addClass web 类名

------解决方案--------------------
#numb.bg{background-color:White;border-bottom: 1px solid white;}
 写成.bg{background-color:White;border-bottom: 1px solid white;}就无法被调用

我觉得不存在这种问题。
有可能是本身#numb有系统默认设置的CSS。
而设置#numb.bg的优先等级优先于默认的。所以能看到效果。