Wrox Programmer Forums
|
BOOK: Beginning JavaScript 4th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 4th Edition by Paul Wilton, Jeremy McPeak; ISBN: 978-0-470-52593-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 4th Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2011, 02:47 PM
Registered User
 
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question DOM nodetype

hello there,

Just a quick question on chapter 12 example 2:
I get the idea of navigating the DOM tree structure,
but can please elaborate on the conditional statement such as:

Code:
if (headElement.nextSibling.nodeType == 3)
{
 bodyElement = headElement.nextSibling.nextSibling;
}
What I think I know:
The statement above is for browsers that consider a "whitespace" a node.
That's why there are "nextSibling.nextSibling" for the purpose of skipping whitespace?

If so,
The integer value 3 (according to Appendix C) is TEXT_NODE, and white space is considered a TEXT_NODE?

Thanks,
tdatu
 
Old March 18th, 2011, 07:33 PM
jmcpeak's Avatar
Wrox Author
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Howdy, tdatu.

Yes, nextSibling.nextSibling is for browsers that count whitespace in between elements as a node in the DOM. To answer your second question, yes, whitespace is text in the DOM.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in writing within "" by DOM. Somesh XSLT 1 March 5th, 2007 07:27 AM
DOM Perseus Java Basics 3 May 4th, 2006 08:50 AM
How to .... Dom Document namitjung PHP How-To 4 July 7th, 2005 12:17 AM
DOM PS C++ freezotic BOOK: Beginning Java 2 0 August 3rd, 2004 11:39 AM
XML DOM / ASP 3.0 xica XML 1 July 13th, 2004 12:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.