spacer
Yehuda Shiran July 8, 2001
The Attribute Node
Tips: July 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Netscape 6 and Internet Explorer 6 support the attribute object. One way to create an attribute node is via the document.createAttribute() command:

attObj = document.createAttribute("foo");

The attribute node is very unique. It is not anyone's child, and it does not belong to the document object. It is a depository for an attribute value. You change the attribute value via:

attObj.value = newValue;

You can query the attribute name and its value with attObj.name and attObj.value, respectively. We put the following two lines in the header of this tip:

attObj = document.createAttribute("A JavaScript Reference");
attObj.value = "Doc JavaScript";

Click the following buttons to detect the attribute name and value in Netscape 6 or Internet Explorer 6. Click them in Internet Explorer 5.5 and observe the error message:

Here is how we defined these buttons:

FORM>
<INPUT TYPE="button" onClick="javascript:alert(attObj.name)" VALUE="Print Attribute Name">
</FORM>
<FORM>
<INPUT TYPE="button" onClick="javascript:alert(attObj.value)" VALUE="Print Attribute Value">
</FORM>


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint