<a> in a cell Jquery event not firing, but every other link does

时间:2019-04-05 13:34:21

标签: javascript jquery html

I'm working with Jquery.
I have several link with class "ajax-link" that does reload #content div. However, another link in a <td> doesn't fire my event (even if it has "ajax-link" class same as the other) and reload all page. How can I fix it ?

I tried several way, the last one is:

$('table > tr > td > a.ajax-link').click(function (event) {

working one (not in table):

$('.ajax-link').click(function (event) {
    event.preventDefault();
    event.stopPropagation();
    $('#content').load($(this).attr('href')+ ' #content > *');
});
<li>
    <a href="http://laravel:8000/employees" class='ajax-link'>Employees</a>
</li>

not working:

<table class="table">
    <tr>
         <td class="id">
             <a href="http://laravel:8000/projects/1" class='ajax-link'>Project 1</a>
         </td>
    </tr>
</table>

I expect that also <a> link in <td> works like other and reload #content div.

0 个答案:

没有答案