15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with both<br />

the contentEditable and isContentEditable properties on the myP and nested<br />

myEM elements (reload the page to start with a known version). Check the current<br />

setting for the myEM element by typing the following statement into the top text field:<br />

myEM.isContentEditable<br />

This value is false because no element upward in the element containment<br />

hierarchy is set to be editable yet. Next, turn on editing for the surrounding myP<br />

element:<br />

myP.contentEditable = true<br />

At this point, the entire myP element is editable because its child element is set,<br />

by default, to inherit the edit state of its parent. Prove it by entering the following<br />

statement into the top text box:<br />

myEM.isContentEditable<br />

While the myEM element is shown to be editable, no change has accrued to its<br />

contentEditable property:<br />

myEM.contentEditable<br />

This property value remains the default inherit. You can see an additional example<br />

of these two properties in use in Listing 15-7.<br />

isDisabled<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with both<br />

the disabled and isDisabled properties on the myP and nested myEM elements<br />

(reload the page to start with a known version). Check the current setting for the<br />

myEM element by typing the following statement into the top text field:<br />

myEM.isDisabled<br />

This value is false because no element upward in the element containment<br />

hierarchy is set for disabling yet. Next, disable the surrounding myP element:<br />

myP.disabled = true<br />

At this point, the entire myP element (including its children) is disabled. Prove it by<br />

entering the following statement into the top text box:<br />

myEM.isDisabled<br />

27<br />

elementObject.isDisabled

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!