JQuery multiple selectors with window or document

I know how to use multiple CSS selectors with jQuery, but how can I bind an event listener to multiple selectors when one of them is an object, like documentor window.

The following does not work:

$('html, body', document).scroll(function () {
    if(Screen.detectScroll() === 'down') {
        self.hide();
    } else {
        self.show();
    }
});
+4
source share
1 answer

You can use jQuery Add () to add selectors.

$('html, body').add(document).scroll(function () {
    if(Screen.detectScroll() === 'down') {
        self.hide();
    } else {
        self.show();
    }
});
+5
source

Source: https://habr.com/ru/post/1548699/


All Articles