Solved

firstChild works in ie but not ff

Posted on 2007-11-15
5
636 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

939 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now