Wikipedia:Reference desk/Archives/Computing/2017 February 23
Appearance
Computing desk | ||
---|---|---|
< February 22 | << Jan | February | Mar >> | February 24 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
February 23
[edit]The Jquery object
[edit]browser.window.document.element.console
Above is the traditional Js object chain. Where should the Jquery object be inserted inside this chain? (I would bet, right after document). Ben-Yeudith (talk) 15:17, 23 February 2017 (UTC)
- Well, unless I'm mistaken, there is no definitive JQuery object. Rather, there's the JQuery function ($) which returns an existing object from the DOM (or from the window, I believe, though I've always accessed the window through CSS). So I don't think there's really a clear answer to this. JQuery itself is an extension of javascript, so it should be at a lower level than the element, because the <script> element contains the code. Also, I'm pretty certain there's no way to go higher than the window with JS or JQuery, so having the browser at the beginning is a little confusing. I could be wrong, however. I'm just a code monkey, not a JS or JQ guru. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 15:46, 23 February 2017 (UTC)
- It's true that jQuery [sic] is a function (usually aliased to $), but it's also an object (as all functions are in JavaScript), and is a member of
window
(i.e. it has 'global scope', so you can call it from anywhere in your code without having to qualify it). As well as being a function it also has members, most of which are themselves functions: for example$.ajax()
and its related functions such as$.get()
and$.get()
. There's perhaps some confusion about the things that are returned by the jQuery function, as invar myItem = $('#myId');
, which are sometimes called 'jQuery objects' or 'jQuery object instances', and are things that you can perform actions on, such as$("#myId").fadeOut("slow");
. (The global jQuery object doesn't have most of these 'action' functions:$.fadeOut
is undefined.) AndrewWTaylor (talk) 16:18, 23 February 2017 (UTC)but it's also an object (as all functions are in JavaScript)
I didn't consider that, but you're right, of course. So yes, it would sit parallel with the document. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 16:56, 23 February 2017 (UTC)
- It's true that jQuery [sic] is a function (usually aliased to $), but it's also an object (as all functions are in JavaScript), and is a member of