Solved

firstChild works in ie but not ff

Posted on 2007-11-15
5
641 Views
Last Modified: 2013-11-19
function deactivate_main_menu_item(elmnt)
{
      elmnt.style.backgroundColor = "#C1C1C1";
      elmnt.firstChild.style.color = "black";
}

The above function works fine in ie but not in ff, the td background colour changes but then the href color does not change.
0
Comment
Question by:shaun_hester
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 125 total points
ID: 20288954
Show the call and what you are calling it from

If you have whitespace, then that is the fristChild in FF
0
 

Author Comment

by:shaun_hester
ID: 20289003
td onmouseover="activate_main_menu_item(this)" onmouseout="deactivate_main_menu_item(this)">
      <a HREF="default.asp">Home</a>
</td>
0
 

Author Comment

by:shaun_hester
ID: 20289009
ok so i've changed the above line to

<td onmouseover="activate_main_menu_item(this)" onmouseout="deactivate_main_menu_item(this)"><a HREF="default.asp">Home</a></td>

with no spaces and works perfectly.

So my next question is how do i use the td element as the root and find all href nodes?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20289132
Like this:
<table>
<td><a href="#">Test0</a></td>
<td>
<a href="#">Test1</a>
<a href="#">Test2</a>
<a href="#">Test3</a>
</td>
<td>
<a href="#">Testa</a>
<a href="#">Testb</a>
<a href="#">Testc</a>
</td>
</tr>
</table>
<script>
var table = document.getElementsByTagName('table')[0]
var secondCell = table.rows[0].cells[1];
var links = secondCell.getElementsByTagName("a");
alert(links.length+':'+links[2].innerHTML)
</script>

Open in new window

0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 125 total points
ID: 20289151
Or in your case

<script>
function showSiblingLinks(link) {
  var links = link.parentNode.getElementsByTagName("a");
  alert(links.length+':'+links[2].innerHTML)
return false
}
</script>
 
 
<table>
<td><a href="#">Test0</a></td>
<td>
<a href="#">Test1</a>
<a href="#">Test2</a>
<a href="#" onClick="return showSiblingLinks(this)">Test3</a>
</td>
<td>
<a href="#">Testa</a>
<a href="#" onClick="return showSiblingLinks(this)">Testb</a>
<a href="#">Testc</a>
</td>
</tr>
</table>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question