0
我有一個表格,我希望可點擊的行,但是在我的某個列中也有一個按鈕,當它按下時應該執行替代操作。使用jQuery製作可點擊的行並排除子元素
HTML:
<table>
<tr data-url="link.html">
<td>Some Text Value <input type="button" value="Submit" onclick="otherFunction()"></td>
</tr>
<tr data-url="link2.html">
<td>Some Text Value <input type="button" value="Submit" onclick="otherFunction()"></td>
</tr>
<tr data-url="link3.html">
<td>Some Text Value <input type="button" value="Submit" onclick="otherFunction()"></td>
</tr>
</table>
的jQuery:
$(document).ready(function() {
$('table tr:not(input)').click(function() {
var href = $(this).attr("data-url");
if(href) {
//console.log('redirect to:' + href);
window.location = href;
}
});
});
目前,當我點擊按鈕的頁面仍然重定向儘管jQuery選擇不含任何輸入。我是否錯誤地使用了:not
?
你能分享'otherFunction()的代碼;'呢? – itzmukeshy7