Jquery:在表头和tfoot中附加带有所有锚点的click事件

Jquery:在表头和tfoot中附加带有所有锚点的click事件,jquery,Jquery,这是我的样品台。我只是没有在这里包括TFootHTML <table class="test-table"> <thead> <tr class="webgrid-header"> <th scope="col"> <a href="http://localhost:13562/page1">ID</a></th> <th scope="col"> <a hr

这是我的样品台。我只是没有在这里包括TFootHTML

<table class="test-table">
<thead>
<tr class="webgrid-header">

    <th scope="col">
    <a href="http://localhost:13562/page1">ID</a></th>

    <th scope="col">
    <a href="http://localhost:13562/page1">First Name</a></th>
    </tr>
    </thead>
    </table>

我犯错误的地方。

你应该像下面这样做。使用
.webgrid页眉a、.webgrid页脚a
而不是
.webgrid页眉.webgrid页脚a

$(document).on('click', '.webgrid-header a, .webgrid-footer a', function (event) {
    event.preventDefault();
    alert('Click on link');
});

你应该像下面这样做。使用
.webgrid页眉a、.webgrid页脚a
而不是
.webgrid页眉.webgrid页脚a

$(document).on('click', '.webgrid-header a, .webgrid-footer a', function (event) {
    event.preventDefault();
    alert('Click on link');
});

使用
.webgrid页眉a、.webgrid页脚
a而不是
.webgrid页眉.webgrid页脚a

检查


使用
.webgrid页眉a、.webgrid页脚
a而不是
.webgrid页眉.webgrid页脚a

检查


使用
。.webgrid页眉a、.webgrid页脚a'
使用
。.webgrid页眉a、.webgrid页脚a'
我使用了它,但不起作用。基本上,页面中有一个动态脚本,当点击链接时,它调用服务器端函数。可能是脚本首先触发,这就是为什么您的脚本无法工作。什么都可以做?你说的动态脚本是什么意思?使用
event.preventDefault()
防止单击
时重定向@如果我使用event.preventDefault(),那么ajax调用可能会停止。我想在单击链接时调用我的函数,然后开始ajax调用,但ajax相关代码不在我手中,而是自动注入到我的页面中。那么您的建议是什么呢。
ajax
调用不应该因为
e.preventDefault()
而停止@如何暂停ajax调用几分钟。我已经看到,如果我显示警报框,那么它将被挂起,当单击警报上的ok按钮,然后ajax调用start。我使用了它,但不起作用。基本上,页面中有一个动态脚本,当点击链接时,它调用服务器端函数。可能是脚本首先触发,这就是为什么您的脚本无法工作。什么都可以做?你说的动态脚本是什么意思?使用
event.preventDefault()
防止单击
时重定向@如果我使用event.preventDefault(),那么ajax调用可能会停止。我想在单击链接时调用我的函数,然后开始ajax调用,但ajax相关代码不在我手中,而是自动注入到我的页面中。那么您的建议是什么呢。
ajax
调用不应该因为
e.preventDefault()
而停止@如何暂停ajax调用几分钟。我已经看到,若我显示警报框,那个么它将被挂起,当单击警报上的ok按钮时,ajax调用开始。
$(document).on('click', '.webgrid-header a, .webgrid-footer a', function () {
    alert('Click on link');
});