inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Sept 18, 2019 9:39:03 GMT -8
D'oh! I've seen/used that before in css. Not sure why the right neuron didn't fire. Maybe I'm accustomed to seeing it with a space between the > and the element. Or maybe because I'm accustomed to seeing the parent element defined directly rather than as part of the find method. Anyway, thanks! I understand it now. jQuery deals in arrays, so when you do a lookup for $('a') or in this case create an $('<a>') element you get back an array of zero or more DOM elements, to get one element out of that array jQuery offers you the eq and get but an even easier way is to just use the array index to pop out the DOM element so you can then add to the href the DOM way rather than having to go through jQuery's attr() method which would require me to use attr() twice; once to get current value then a second time to write current value back with the appended IP ... much easier to just drop down to native javascript like I did and append the IP directly to the href attribute. I get the overall gist of this but the concept of jQuery arrays is still brand new to me. I reckon you've taught me as much as you can on this, given my limited overall understanding. I'll go back to the reference sites and do some more reading on jQuery. I get the feeling that fully understanding arrays and indices will be very important. I'm grateful for your patience and the time you've spent.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 19, 2019 1:56:22 GMT -8
I get the overall gist of this but the concept of jQuery arrays is still brand new to me. I reckon you've taught me as much as you can on this, given my limited overall understanding. I'll go back to the reference sites and do some more reading on jQuery. I get the feeling that fully understanding arrays and indices will be very important. jQuery is a library that is using the JavaScript language. So ignore jQuery, read up on native Arrays instead. What Chris explained is how native Arrays work. There is really nothing special going on under the hood of jQuery when querying a collection, it's mostly a wrapper with useful methods. // This is the same let elems_1 = document.getElementsByTagName("a");
// As this (Sizzle uses this now) let elems_2 = document.querySelectorAll("a");
// And this (Underneath jQuery the Sizzle engine is used) let elems_3 = $("a"); developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|