How to handle event on clicking a link in td?
How to handle event on clicking a link in td?

Hi,
I have a td as defined below.
<td class=" cell-td">
<a href="#"class="test"></a>
</td>
I need to perform some action on the click of link "a.test".
I tried doing:
$('#profile-table tbody').on('click', 'a.test', function (e) {
e.preventDefault();
console.log('test1');
});
It is not logging the value.
can u please help me in understanding the event handler for the links in td?
This discussion has been closed.
Answers
Two possibilities:
You need a space before the class. I think that is the most likely issue.
The other is that your selector isn't picking anything up. A way to test that would be:
If
0
is shown in the table, then either the element isn't in the document when that code is run, or tbody isn't present, or the id is wrong. We'd need a test case to say for sure.Allan