jQuery selector for document and another element

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2011-11-13T01:46:30Z Indexed on 2011/11/13 1:50 UTC
Read the original article Hit count: 357

Filed under:
|

Can I merge these in jQuery? I'm using the HotKeys plugin.

$(document).bind('keydown', 'n', cycleNoise);
$(document).bind('keydown', 's', pickRandom);
$(document).bind('keydown', 'v', toggleTasks);
$(document).bind('keydown', 't', toggleTimer);
$(document).bind('keydown', 'up', hideTask);
$(document).bind('keydown', 'down', nextTask);
$('#duration').bind('keydown', 't', toggleTimer);
$('#duration').bind('keydown', 'n', cycleNoise);
$('#duration').bind('keydown', 's', pickRandom);
$('#duration').bind('keydown', 'v', toggleTasks);
$('#duration').bind('keydown', 'up', hideTask);
$('#duration').bind('keydown', 'down', nextTask);

In other words, is it possible to use document and '#duration' in the same selector. The following doesn't seem to work:

$(document + ',#duration').bind(...);

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors