Hey everyone,
I'm currently reading Sitepoint's 'Javascript Anthology' and keep
spotting a reference I'm not quite familiar with, such as
'document.getEl ementByTagName( 'p')[0]'. What I want to know is if this
reference points to the first element with the containing object?
Cheers 4 1553
On Mar 29, 11:21 am, "DoomedLung " <doomedl...@goo glemail.comwrot e:
Hey everyone,
I'm currently reading Sitepoint's 'Javascript Anthology' and keep
spotting a reference I'm not quite familiar with,
such as
'document.getEl ementByTagName( 'p')[0]'.
What is happening here is that you are creating an array, and
dereferencing the array, both on the same line.
document.getEle mentsByTagName( 'p') gets an array (actually its a
NodeList, but just think of it as an array).
And document.getEle mentsByTagName( 'p')[0] gets the first item from
that array.
//bar gets the first P tag in the document
var bar = document.getEle mentsByTagName( 'p')[0];
is shorthand for
//foo gets a list of all the P tags in the document
var foo = document.getEle mentsByTagName( 'p');
//bar gets the first P tag from that list
var bar = foo[0];
On Mar 29, 4:46 pm, "Noah Sussman" <blink...@gmail .comwrote:
On Mar 29, 11:21 am, "DoomedLung " <doomedl...@goo glemail.comwrot e:
Hey everyone,
I'm currently reading Sitepoint's 'Javascript Anthology' and keep
spotting a reference I'm not quite familiar with,
such as
'document.getEl ementByTagName( 'p')[0]'.
What is happening here is that you are creating an array, and
dereferencing the array, both on the same line.
document.getEle mentsByTagName( 'p') gets an array (actually its a
NodeList, but just think of it as an array).
And document.getEle mentsByTagName( 'p')[0] gets the first item from
that array.
//bar gets the first P tag in the document
var bar = document.getEle mentsByTagName( 'p')[0];
is shorthand for
//foo gets a list of all the P tags in the document
var foo = document.getEle mentsByTagName( 'p');
//bar gets the first P tag from that list
var bar = foo[0];
I thought as much. Just needed to clear it up.
Cheers dude :)
On Mar 29, 9:46 am, "Noah Sussman" <blink...@gmail .comwrote:
'document.getEl ementByTagName( 'p')[0]'.
What is happening here is that you are creating an array, and
dereferencing the array, both on the same line.
document.getEle mentsByTagName( 'p') gets an array
It's not array, it's a collection.
scripts.contact wrote:
On Mar 29, 9:46 am, Noah Sussman wrote:
>>'document.get ElementByTagNam e('p')[0]'.
What is happening here is that you are creating an array, and dereferencing the array, both on the same line. document.getEle mentsByTagName( 'p') gets an array
It's not array, it's a collection.
The object returned from - getelementsByTa gName - is a - NodeList
- not a collection. In a class-less language like ECMAScript being
a - NodeList - is just a matter of having the specified properties,
methods and characteristics of a - NodeList -, and as a result all
objects implementing the - HTMLCollection - interface are also
implementing the - NodeList - interface (so are NodeLists). But
NodeLists are not necessarily also HTMLCollections , and it would
be dangerous to assume that the objects returend from calls to
- getElementsById - have properties beyond those specified.
In class-based terminology it may be said that - HTMLCollection
- extends - NodeList, and actual examples may be implemented in
that way. In such a context it would be possible to case an -
HTMLCollection - into a - NodeList -, but not the other way around.
Richard. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon |
last post by:
Am using the following code.
<script language="JavaScript1.2">
function setquantity(productindex,productquantity)
{
//create the reference object
irefname_none = eval("document." + productindex + "none");
<snip>
|
by: Daniel Reber |
last post by:
I have an exe that serializes one of it's classes to disk. I also have the
exact same .cs file that contains the class that was serialized, in a
Windows service application. I am trying to load that file every time the
service starts. When I try to load it I get this error
File or assembly name PXPJobSetup, or one of its dependencies was not found.
I am not sure what I need to do.
Thanks
|
by: Macka |
last post by:
A few pieces of information first:
* I have a class called Folder which represents a row of data in a
database table. The data access side of things is not an issue.
* The table has a parent column which references itself (ie. Adjacency
or parent/child model)
* I have a public property called 'Parent' which returns me a new
reference to a Folder instance containing the data of the parent row.
|
by: Wilfried Mestdagh |
last post by:
Hi,
When I use same variable for a new created object, then whill the old one
destroyed by garbage collection, or do I first have to set it to null ?
eg:
SomeObject o = new SomeObject();
// and a while later:
o = new SomeObject();
|
by: DogEye |
last post by:
In the C# , I want to change the object only after the user click the
"Submit" button , so I first new an object and use the "=" to get the object
in memory , I found that the operation "=" only get a reference to the
target object which I want to copy , how can I do copy it ?
| |
by: Christopher D. Wiederspan |
last post by:
This is a bit tough to figure out the best way to ask, but here it goes.
I've got a class, say MyObject, and everytime this class is instanciated, I
actually want to get a reference to an existing object. Maybe better stated
by example:
public class SomeClassA {
MySpecialObject A;
public SomeClassA() {
this.A = new MySpecialObject();
|
by: DrConti |
last post by:
Dear Python developer community,
I'm quite new to Python, so perhaps my question is well known and the
answer too.
I need a variable alias ( what in other languages you would call "a
pointer" (c) or "a reference" (perl))
I read some older mail articles and I found that the offcial position
about that was that variable referencing wasn't implemented because
it's considered bad style.
There was also a suggestion to write a real problem...
|
by: woger151 |
last post by:
If I write
$x = new some_class($init_data1);
and then
$x = new some_class($init_data2);
does the first object (constructed with $init_data1) get destroyed, or
do I have to call unset() for that? And am I guaranteed that after
the second call the value of $x will be as if the first call was never
made?
|
by: Summercool |
last post by:
The meaning of a = b in object oriented languages.
====================================================
I just want to confirm that in OOP, if a is an object, then b = a is
only copying the reference.
(to make it to the most basic form:
a is 4 bytes, let's say, at memory location 0x10000000 to 0x10000003
|
by: Joe |
last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing
quite often the following (this example taken from a wiki):
$wakka =& new Wakka($wakkaConfig);
What exactly is the =&, and why is it different from = ?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |