?
Solved

firstChild works in ie but not ff

Posted on 2007-11-15
5
Medium Priority
?
646 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 500 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 500 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

800 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