I have some search fields on a page. Upon pressing 'enter' anything in these fields will then get filtered on for a dataset that's displayed on a table.
$("document").on('keyup', (e) => {
if (e.keyCode === 13) {
searchAndDraw();
}
});
My issue is that I have a table #myTable with some textareas in tds . Hitting 'enter' inside a textarea also triggers the search as the table is inside the document.
How can I apply this keyup event to the doc but exclude #myTable?
I tried $("document:not(#tliId)").on('keyup'... but that does not work.
$("document :not(#tliId)")-- you need a space to match a descendant element.$(document).children(":not('#tliOd')").on("keyup", function(){}). You could also check the ID inside the callback.