我已經建立了它看起來像這樣的功能jQuery選擇:jQuery選擇。不是()不工作
$('html').not('.table-main tr[selected]').mousedown(function(e) {
但不知何故,它不是在所有的過濾,我不明白爲什麼。 即使我只是離開('.table-main')對於選擇器,我仍然在點擊表格時觸發該函數......這是什麼問題?
使用文件或「身體」,而不是「HTML」沒有幫助,因爲文件是不是在所有。不觸發()和「體」的結果相同。
編輯: 剛剛嘗試使用表格外的另一個塊,它的工作原理。有沒有機會我不能在桌上使用它?
UPDATE2:按照要求,這裏是表的渲染HTML代碼:
<table border="0" cellspacing="2px" cellpadding="5px" class="table-main">
<tr id="tablefields">
<th style="padding: 0;">
<table cellpadding="0" cellspacing="0" border="0" align="center">
<tr><th><div class="tr-head-get" id="tr-get-0">Name</div></th></tr>
<tr><th><div class="th-header" id="th-header-0" style="top: 54px;">Name</div></th></tr>
</table>
</th>
<th style="padding: 0;"></th>
</tr>
<tr id='table_form_new_device' class='table_form_class'>
<form accept-charset="UTF-8" action="/devices" class="new_device" data-remote="true" id="new_device" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="T2dSeZpxxvgJdTP+yoE7BrVODzqJ95gyVu9Wh/v7oP8=" /></div>
<th class='tablefield'>
<input id="device_devicename" name="device[devicename]" size="10" type="text" />
</th>
<th>
<div class='submitbox' id='submitbox_new_device'>S</div>
<script>
$('#submitbox_new_device').click(function (event) {
$('#new_device').submit();
});
</script>
</th>
</form></tr>
</table>
<div class="dropdown-button" style="margin: 0 2px;">Filter</div>
此外,它可以是事件冒泡問題。閱讀更多關於事件順序的信息http://www.quirksmode.org/js/events_order.html – antyrat 2012-04-04 17:04:02
所以你試圖選擇每個未被選中的tr?看看[選擇]選擇器的[jQuery文檔](http://api.jquery.com/selected-selector/)。你的語法看起來有點偏離。但是,一些DOM示例會幫助您更好地幫助您。 – Primus202 2012-04-04 17:04:42