我有一個包含多行的表格。點擊每一行會將用戶重定向到唯一的網址。 我的問題是如何應用表格行上的單擊事件,但td與動作類不應該受可點擊行的影響? 我試過了:不是jQuery選擇器,但不幸的是我對jQuery很新。謝謝!將jQuery函數應用於表格行但不是第一個表格數據
這裏是我的表:
<table id="tblHotel">
<thead>
<tr>
<th class="sorting_disabled"> </th>
<th>ID</th>
</tr>
</thead>
<tbody>
<tr id="1" >
<td class="actions">
<a href="hotel/update/1"><i class="icon-pencil"></i> Edit</a>
<a href="#"><i class="icon-trash"></i> Delete</a>
</td>
<td>1</td>
</tr>
</tbody>
這裏是jQuery的AJAX:
$("#tblHotel tbody tr").click(function(){
var hotelid = $(this).attr('id');
$.ajax({
type: "POST",
url: "<?=site_url('hotel/view')?>/" + hotelid,
success: function(data){
$('.hiddenSidebar').html(data).show('slide', { direction: 'right' }, 300);
},
error: function(){
alert('error!');
}
});
}).not('tr td.actions');
怎麼樣的價值每個tr的id是多少?這有多行與獨特的ID .. –
@markyorky對不起,我沒有得到你的意思, –
這工作!謝謝:) @Arun –