[Javascript] Trouble with id

Troy III Ajnej trojani2000 at hotmail.com
Tue Jun 5 08:55:25 CDT 2007


Helo Del,
this code works as expected on both, IE and FX (strictmode): 
 
<a href="#" onMouseOver = toggle_visibility('hint4')><img src="../../image/icon_toggle.jpg" width="22" height="22" border="0"></a>
<span class = "hidden_hint" id=hint4> Add - <img src="../images/sq_root_7.gif" align="absmiddle"> to both sidesof the equation.</span>
 
function toggle_visibility(id) {  var e = document.getElementById(id);
  if(e.style.visibility != 'visible')   e.style.visibility = 'visible';  else   e.style.visibility = 'hidden'; } 
 
One thing I don't understand is what's the use of a toggle function if
there is no "onmouseout" event defined? Since you'll have to mouseover
twice to toggle it, consider defining the mouseout also:
<a href="#"onMouseOver = toggle_visibility('hint4') 
onMouseOut = toggle_visibility('hint4')>
...
Regards
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                        Troy III                            progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


> From: del at delweg.com> To: javascript at LaTech.edu> Date: Mon, 4 Jun 2007 22:13:51 -0500> Subject: [Javascript] Trouble with id> > 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> > > _______________________________________________> Javascript mailing list> Javascript at LaTech.edu> https://lists.LaTech.edu/mailman/listinfo/javascript
_________________________________________________________________
Play free games, earn tickets, get cool prizes! Join Live Search Club. 
http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20070605/7c15adc4/attachment.htm>


More information about the Javascript mailing list