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