3
I use Ubuntu 13.10 and know few HTML editors for it.
The editor I use is Bluefish, which has helped me a lot. I am learning Javascript by w3shcool and at the moment I am in the DOM nodes part, and as it is a little more complicated to understand, I searched for a video on the internet that would help me understand about us, and I found a video explaining the "family tree" of html.
When I tested the following code:
window.onload = function()
{
var div = document.getElementsByTagName("div").item(0);
var ul = div.childNodes.item(0);
Alert(ul);
}
I figured he should return as object HTMLULLISTELEMENT
; But it is returned as: Object text.
Using firebug I discovered that the problem is the space between div and ul or is the tab that the editor Bluefish gives or is it is considering the space as text.
How can I fix this?
The well explained video about tree (nodes) is this:
http://www.youtube.com/watch?v=ruV-ZLn6gl8
The complete code below:
<html>
<head>
<title>Core Api</title>
<script>
window.onload = function()
{
var div = document.getElementsByTagName("div").item(0);
var ul = div.childNodes.item(0);
alert(ul);
}
</script>
</head>
<body>
<h2>Árvore</h2>
<div>
<ul>
<li id="item1">
Primeiro
<span style="color:blue;">item</span>
<ul>
<li id="item 1.1">item1.1</li>
<li id="item 1.2">item1.2</li>
<li id="item 1.3">item1.3
<ul>
<li id="item 1.3.1">item1.3.1
</ul>
</li>
</ul>
</li>
<li>item2</li>
<li>item3</li></ul></div>
</body>
</html>
I thought an if to solve this, the big problem is that when I want to use the text Node. I will try this method.
– fmaskes