user525146
user525146

Reputation: 3998

Find hyperlink in the table cells

I have a table with some data and last column has a hyperlink for all the rows in the table. I need to open a dialog on click of the hyperlink.

<table id="tableId">
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td><a href="">edit</a></td>
</tr>
</table>

$("#tableId tr a[href]").on("click", function() {
   console.log("Hello World");
   $("<div></div>).dialog({});
});

My console doesn't show hello world probably some error in the jquery code

Upvotes: 0

Views: 94

Answers (1)

Adil
Adil

Reputation: 148110

Closing Quote missing "<div></div>"

 $("<div></div>").dialog({});

Live Demo

It is better to give hash # in href like this,

<a href="#">edit</a>

You code would be

$("#tableId tr a[href]").on("click", function() {
   console.log("Hello World");
   $("<div></div>).dialog({});
   return false; 
});

Upvotes: 3

Related Questions