[Javascript] Trouble with id

Del Wegener del at delweg.com
Mon Jun 4 22:13:51 CDT 2007


Good Day;

This is the JavaScript function
function toggle_visibility(id)
 {
  var e = document.getElementById(id);
  if(e.style.visibility != 'visible')
   e.style.visibility = 'visible';
  else
   e.style.visibility = 'hidden';
 }

This is the HTML which does the calling
<a href="#"onMouseOver = toggle_visibility(104)>
<img src="../../image/icon_toggle.jpg" width="22" height="22" 
border="0"></a>
  <span class = "hidden_hint" id=104>
   Add -<img src="../images/sq_root_7.gif" align="absmiddle"> to both sides
of the equation.
</span>

This works fine when I use a number for the id.
However I would prefer(reasons involve the rest of the page) to use "hint4" 
for the ID
When I use hint4 with or without quotes, the whole toggle fails.
An ALERT inserted  in the function returns object for id when I use hint4
and returns the number when I use a number.

I do not understand.
Can someone explain what goes wrong when I use id = hint4 ?

Thanks for any help.

Del





More information about the Javascript mailing list