Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

firstChild works in ie but not ff

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

609 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