What is the difference between the document selector and window selector?
问题 I have the following JQuery function that takes user input and displays it on screen. When I select for both $(document) and $(window) the function works. What is the disadvantage to using either selector? Where can I read more on these selectors and their differences? Thank you in advance. $(document).keypress(function(e) { if(e.keyCode == 13) { var id = $("input#example").val() console.log(id); $('#data').append(id); } }); 回答1: While using the window or document object in a jQuery dom