> "Ian Collins" <ia******@hotmail.com> wrote:
news:11***************@drone2-svc-skyt.qsi.net.nz....
BootNic wrote:
[snip]
<script type="text/javascript">
function turn(){
var elm,i,j,x,y,z;
elm=document.getElementsByTagName('a');
for (i=0, j=elm.length; i<j; i++) {
x=elm[i];
y=x.parentNode.tagName.toLowerCase();
z=x.parentNode.parentNode.className;
if(y=='li'&&z=='easyMenu'){
x.style.color='#008000';
}
}
}
That's only looking for specific elements with a single class, the
OP was looking for a means of finding all elements to which a CSS
style applies. This is a little more complex and one would have to
check computed (or currentStyle in IE) style values for all
elements.
An near as I can tell ".easyMenu li>a{}" seem to be a emements that
have a parent li element, of which the li parent has a class of easyMenu.
Well I suppose this did not allow for more then one class. A small
adjustment is in order to allow for more then one class.
Maybe set z=x.parentNode.parentNode.className.match(/\beasyMenu\b/)
and then set the next if statement to if(y=='li'&&z)
Is it more complex then this?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function turn(){
var elm,i,j,x,y,z;
elm=document.getElementsByTagName('a');
for (i=0, j=elm.length; i<j; i++) {
x=elm[i];
y=x.parentNode.tagName.toLowerCase();
z=x.parentNode.parentNode.className.match(/\beasyMenu\b/);
if(y=='li'&&z){
x.style.color='#008000';
}
}
}
</script>
<style type="text/css">
..easyMenu li>a{
color:#FF0000;
}
..easyMenu2 a{
background-color:#5F9EA0;
}
..easyMenu3 a{
font-size:1.5em;
}
</style>
<title></title>
</head>
<body>
<button onclick="turn()">check</button>
<ol class="easyMenu3 easyMenu easyMenu2">
<li><a href="#">yup</a> <span><a href="#">nope</a></span>
<a href="#">yup</a></li>
<li><span><a href="#">nope</a></span></li>
<li><a href="#">yup</a> <a href="#">yup</a></li>
</ol>
</body>
</html>
--
BootNic Saturday, March 18, 2006 10:54 PM
A person without a sense of humor is like a wagon without springs,
jolted by every pebble in the road.
*Henry Ward Beecher*