这是我的html菜单按钮:
<tr>
<td><a href="http://exmple.com/2014/09/28.html">23</a></td>
<td><a href="http://exmple.com/2014/09/24.html">24</a></td>
<td><a href="http://exmple.com/2014/09/25.html">25</a></td>
</tr>如何在当前URL上添加该类?
<td class="active"><a href="http://example.com/2014/09/25.html">25</a></td>我怎样才能做到这一点呢?
发布于 2014-09-26 09:29:06
$('table td a').click(function(e){
$('table td').removeClass('active');
$(this).parent('td').addClass('active');
e.preventDefault();
});.active a{
color: #f00;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<table>
<tr>
<td><a href="http://exmple.com/2014/09/28.html">23</a></td>
<td><a href="http://exmple.com/2014/09/24.html">24</a></td>
<td><a href="http://exmple.com/2014/09/25.html">25</a></td>
</tr>
</table>
这是解决办法。根据你的需要使用它。
https://stackoverflow.com/questions/26056044
复制相似问题