I get to this statement
var elementArray = Core.getElementsByClass("dataTable");
on page 79, so I decide to test it now that I am getting the swing of what’s going on so far…
My Html is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trial 2</title>
<!-- <link type="text/css" href="look.css" rel="stylesheet" /> -->
<script type="text/javascript" src="core.js"></script>
<script type="text/javascript" src="libs.js"></script>
</head>
<body>
<h1>Hello Alert</h1>
<p>
In this cinema masterpiece,
<a id="berenger" href="/name/nm0000297/">Tom Berenger</a> plays
a US soldier working in the Panamanian jungle.
</p>
<ul>
<li>
paragraph
</li>
<li>
unordered list
</li>
</ul>
<p>
There are 2 children of html:
</p>
<ul id="apple">
<li class="secondList">
head
</li>
<li class="secondList">
body
</li>
</ul>
</body>
</html>
my libs.js working just under core.js is:
var coreConnection =
{
init: function()
{
var listItems = document.getElementById("apple");
alert(listItems.nodeName); // test alert
var elementArray = Core.getElementsByClass("secondList");
var firstItem = elementArray[0];
var secondItem = elementArray[1];
alert(firstItem);
alert(secondItem);
}
};
Core.start(coreConnection);
Ok, this works, but I get this alert for the firstItem or second Item of the secondList classes: instead of alerting “head” or “body” as shown fromt that list, I get an alert that says [object HTMLLIElement]. Ok, I see that it is in the right place and all. But I thought it was suppose to give me what was inside the element, not the nodeName or ObjectName or whatever. How do I fix my code so that is says the string that is in the li tag?
Thanks ahead of time
James