日期:2014-05-16 浏览次数:20371 次
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> var products=[ ["blue","medium"], //产品1 ["blue","small"], //产品2 ["red","medium"] //产品3 ]; function select_item(){ //根据上面的products数组 //点击blue,因为blue对应的有2种size,下面的size 2个都能选 //点击red,只存在1种size,给下面<li><a href="#">small</a></li> 加css (addClass("not_selectable")) //点击small,只存在1种color,上面的<li><a href="#">red</a></li> 加css (addClass("not_selectable")) //点击medium,存在2种color,上面的color 2个都能选 } </script> <style type="text/css"> .not_selectable{color:gray;} </style> <div class="properties"> <dl> <dt>color</dt> <dd> <ul> <li><a href="#">blue</a></li> <li><a href="#">red</a></li> </ul> </dd> </dl> <dl> <dt>size</dt> <dd> <ul> <li><a href="#">small</a></li> <li><a href="#">medium</a></li> </ul> </dd> </dl> </div>