I have a table where the first td in trs contains a link. I want this anchor to be launched (clicked) no matter where I click in the containing tr.
I have read and tried many posts and suggestions on this topic, but I cannot get this to work. I tried trigger () and triggerHandle () functions, but it doesn't trigger the snap click that I want.
There must be others who needed to trigger an anchor click when clicking the tr button, so that the user does not need to click the tds anchor link. Is this, of course, a good user interface feature, if possible?
Here is the code I tried:
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="javascripts/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function () {
jQuery("#rowClick tr").click(function (e) {
jQuery("#clickevent", this).trigger("click");
});
});
</script>
</head>
<body id="dt_example">
<table id="rowClick">
<thead>
<tr>
<th style="width: 30px">id</th>
<th style="width: 200px">navn</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="datatabletext.asp?test=1" id="clickevent">1</a></td>
<td>Jesper</td>
</tr>
<tr>
<td><a href="datatabletext.asp?test=2" id="clickevent">2</a></td>
<td>Bjarne</td>
</tr>
<tr>
<td><a href="datatabletext.asp?test=3" id="clickevent">3</a></td>
<td>Søren</td>
</tr>
</tbody>
</table>
</body>
source
share