我有一個表trs中的第一個td包含一個鏈接。我希望這個錨點被觸發(點擊),無論我在哪裏點擊包含tr。jquery:如何觸發tr當tr被點擊時
我已閱讀並嘗試了很多關於此主題的最新帖子和建議,但我無法得到它的工作。我嘗試了trigger()和triggerHandle()函數,但它不會觸發我想要的錨點單擊。
當點擊tr時,必須有其他人需要觸發錨點擊,以便用戶不必點擊tds錨點鏈接。如果可能的話,它肯定是一個不錯的UI功能?
下面是代碼我曾嘗試:
<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">
/* Initialise the table with the required column sorting data types */
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>