jquery - HTML TD 可点击

标签 jquery css html-table

我有一个菜单,您可以在右上角看到 - www.balibar.co

HTML:

    <div id="joinHeader" class="shadow">
            <table id="indexNavigation"><tr>
                <td><a id="navSearch">Search</a></td>
                <td><a id="navLanguages">Languages</a></td>
                <td id="activeNavLink"><a id="navLogin">Login</a></td>
            </tr></table>
    </div>

CSS:

 table#indexNavigation {
width: 100%;
height: 25px;
font-weight: normal;
font-size: 1.1em;
border-collapse: collapse;
 }

 table#indexNavigation td {
text-align: center;
color: white;
width: 33.33%;
border-right: 1px solid #FFF;
cursor: pointer;
 }

table#indexNavigation td#activeNavLink {
border-right: none;
 }

我想让整个 TD 都可以点击。 我添加了光标:指针;到 TD,但它不会亮起,除非在单词上方。 我试着把 <a>外面<td>但这没有用。

是否有使它可点击的技巧。 然后将其连接到 jQuery 以获取点击事件 - 例如:

 $('td#activeNavLink').click(function() {

最佳答案

只需让 td 标签内的链接宽度为 100%。然后它们将占据单元格的整个宽度。

table#indexNavigation td a {
    display: block;
    width: 100%;
    text-align: center;
}

关于jquery - HTML TD 可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7555163/

相关文章:

css - 第 n 个类型的问题。我一定是误解了它是如何工作的

css - Sendgrid 模板 CSS 被忽略

javascript - html 表格如何通过更改悬停时的边框来突出显示列?

javascript - jQuery AJAX 回调函数未按预期工作 :

javascript - jquery 日期时间选择器 null 允许的时间

javascript - 是否存在类似 jQuery.toggle(boolean) 的东西?

html - CSS3 转换 : translate on hover, 带过渡

mysql - 从 codeigniter 中的两个表中选择查询

html - 滚动时表格行内容渗入粘性标题内容 - 相对与绝对定位相关

javascript - 简单的 JQuery 脚本动画不起作用