Forum Moderators: open
The code doesn't run, and it's not throwing any error messages in Firefox or Opera.
That sound like possibly the cssQuery scripts aren't being accessed, but the paths to the scripts look ok to me.
Any help appreciated.. perpetual newbie.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>TEST PAGE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="Play.css">
<script type="text/javascript" src="cssQuery.js"></script>
<script type="text/javascript" src="cssQuery-standard.js"></script>
<script type="text/javascript" src="cssQuery-level2.js"></script>
<script type="text/javascript" src="cssQuery-level3.js"></script>
<script type="text/javascript">
var line1 = cssQuery("div:nth-child(6)")
function test1() {
for (i=0; i<line1.length; i++) {
if (line1.item[i].textNode == "---" && line1.parentNode.item[i].className == "hex") {
line1.parentNode.style.color = "red"; }
}
}
</script>
</head>
<body onload="test1()">
<div id="HEX">
<!-- HEXES row 8 -->
<div class="hex" id="H01">
<p>___</p>
<p>___</p>
<p>___</p>
<p>___</p>
<p>___</p>
<p>___</p>
<p class="num0">1</p></div> (and another 63 divs...)
this needs to happen after onload, try moving it.
<script type="text/javascript">
function test1() {
var line1 = cssQuery("div:nth-child(6)");
for (i=0; i<line1.length; i++) {
if (line1.item[i].textNode == "---" && line1.parentNode.item[i].className == "hex") {
line1.parentNode.style.color = "red"; }
}
}
</script>
Not familiar with cssQuery, looks a lot like jsQuery ?
function test1() {
var line1 = cssQuery("div:nth-child(6)");
for (i=0; i<line1.length; i++) {
if (line1.item[i].textNode == "---") {
line1.parentNode.style.color = "red"; }
}}
It now throws this message: "Error: line1.item is undefined".
This is first attempt at using a js library, from: [dean.edwards.name...] .
" cssQuery() is a powerful cross-browser JavaScript function that enables querying of a DOM document using CSS selectors...
Syntax
elements = cssQuery(selector [, from]);
where selector (required) is a valid CSS selector and from (optional) is a document, element or array of elements which is filtered by selector.
The function returns a JavaScript array of elements. If there is no match, an empty array is returned. "
If the error message is about an item in the array, it sounds like the array is not actually formed?