Wikipedia:Reference desk/Archives/Computing/2017 February 23
{{#ifeq:{{PAGENAME}}|Special:Undelete| |{{#if:|
The Jquery object
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
:: 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 in var 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)
:::{{tq|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)