html - Blogger 事件链接类

标签 html css blogger

这是我的 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>

我怎样才能完成这项工作?

最佳答案

$('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>

这是解决方案。根据您的需要使用它。

关于html - Blogger 事件链接类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26056044/

相关文章:

javascript - 第二次点击打开超链接的最佳方法

javascript - 博主iframe评论表单是否限制自定义?

javascript - 限制固定子 div 的高度滚动到父 div 的高度

html - 如何在 CSS 中创建丝带形状

html - 如何使用 CSS 设置我的 HTML 表单的样式

javascript - 如何将随机类名添加到博客模板中的元素

html - Microsoft Excel 安全警告 - 弹出

javascript - 如何使用 Javascript 使图像在屏幕右侧移动并返回

javascript - 如何使用外观在 IE 中显示菜单列表按钮?