Java Reference
In-Depth Information
{
bodyElement = headElement.nextSibling.nextSibling;
}
else
{
bodyElement = headElement.nextSibling;
}
alert(bodyElement.tagName);
if (bodyElement.firstChild.nodeType == 3)
{
h1Element = bodyElement.firstChild.nextSibling;
}
else
{
h1Element = bodyElement.firstChild;
}
alert(h1Element.tagName);
h1Element.style.fontFamily = “Arial”;
if (h1Element.nextSibling.nodeType == 3)
{
pElement = h1Element.nextSibling.nextSibling;
}
else
{
pElement = h1Element.nextSibling;
}
alert(pElement.tagName);
pElement.style.fontFamily = “Arial”;
if (pElement.previousSibling.nodeType==3)
{
h1Element = pElement.previousSibling.previousSibling
}
else
{
h1Element = pElement.previousSibling
}
h1Element.style.fontFamily = “Courier”
</script>
</body>
</html>
Save this as ch12_examp2.htm . Then open the page in your browser, clicking OK in each of the mes-
sage boxes until you see the page shown in Figure 12-9 (unfortunately, IE does not render the style
changes until all alert boxes have been opened and closed).
Search WWH ::




Custom Search