【发布时间】:2014-10-07 21:25:34
【问题描述】:
我在标题中有两个图标,它们的下拉菜单在单击时会切换。
在每个图标的每个列表项中都有一个“i”标签,它是向下箭头的 Font Awesome。单击每个图标时,通过将类 'fa-chevron-down' 更改为 'fa-chevron-up',箭头变为向上。
但是,如果我单击帮助图标,帮助下拉菜单会向下滑动,如果我然后单击篮子图标,帮助下拉菜单会向上滑动,而篮子下拉菜单会向下滑动。相关图标中的箭头也需要随之更改 - 帮助图标上的箭头需要更改为指向下方,因此课程需要从“fa-chevron-up”更改回“fa-chevron-down” .
例如如果购物篮下拉菜单处于活动状态,则帮助图标“i”标签应具有“fa-chevron-down”类,而购物篮图标“i”标签应具有“fa-chevron-up”类。如果帮助下拉菜单处于活动状态,则购物篮图标“i”标签应具有“fa-chevron-down”类,帮助图标“i”标签应具有“fa-chevron-up”类。
这是一个 jsFiddle:http://jsfiddle.net/2srx4sv2/9/
代码是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="format-detection=no,initial-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width" />
<title>Untitled Document</title>
<link href="http://www.swimmingcover.co.uk/test_new/css/header.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="http://www.swimmingcover.co.uk/test_new/css/font-awesome.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
<script src="http://www.swimmingcover.co.uk/test_new/js/mobile.js" type="text/javascript"></script>
</head>
<body>
<div id="header">
<ul class="hdr_link_icons">
<li class="icon_basket"><img src="http://www.swimmingcover.co.uk/test_new/images/header/icon_basket.jpg" alt="My basket" /><i class="fa fa-chevron-down"></i></li>
<li class="icon_help"><img src="http://www.swimmingcover.co.uk/test_new/images/header/icon_help.jpg" alt="Help Section" /><i class="fa fa-chevron-down"></i></li>
</ul>
<ul class="hdr_dropdown_area" id="help_dropdown">
<li><a href="">Your Account <span class="hdr_link_arrow">»</span></a></li>
<li><a href="">Corporate Sales <span class="hdr_link_arrow">»</span></a></li>
<li><a href="">Got a voucher? <span class="hdr_link_arrow">»</span></a></li>
</ul>
<div id="dvBasket" class="basketoverview hdr_dropdown_area">
<div class="heading">Total items: 1</div>
<div class="item">
<div class="details">
<a href="#">
Product 1
</a>
<br />
<span class="price">£39.00</span>
</div>
</div>
<div class="item">
<div class="details">
<a href="#">
Product 2
</a>
<br />
<span class="price">£39.00</span>
</div>
</div>
<div class="bottom">
<a title="Your basket" href="#">View Basket</a>
</div>
</div>
</div>
</body>
</html>
【问题讨论】:
-
jsfiddle 中的 font-awesome css 没有加载
标签: jquery toggle font-awesome toggleclass