Jump to content

DOM question


KevinM1

Recommended Posts

Say I have the following html document:

[code]
<?php

//using php in my code block because the board always breaks on me if I try using just html

?>

<html>
<head><title>Blah</title></head>

<body>

<div>This chicken tastes <span style="font-weight: bold;">really</span> good.</div>

</body>
</html>

<?php

//more php just to make sure the board doesn't break

?>
[/code]

What would be the div's text node(s)?  Would it be "This chicken tastes good?"  Or would there be two text nodes because of the span ("This chicken tastes," and "good")?
Link to comment
https://forums.phpfreaks.com/topic/26330-dom-question/
Share on other sites

If you just accessed document.getElementsByTagName("div")[0].childNodes and looked for text nodes, there would be two, "This chicken tastes " and " good."  document.getElementsByTagName("div")[0].childNodes[1].firstChild.nodeValue would be "really" so there are actually three text nodes inside of the div.
Link to comment
https://forums.phpfreaks.com/topic/26330-dom-question/#findComment-120644
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.