Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.