Actinia
03-21-2012, 09:50 PM
I have many examples within my page of the form:
<a id="L1" href="#" onclick="return showSpan();" onblur="return hideSpan();"><span> ... </span></a>
The page is styled so that hovering over the link displays the contents of the hidden <span> as a block without any javascript. I want this to work (that is display the span as a block) when the user tabs onto a link (and presses Return/Enter). When the user tabs away, it should hide the <span>.
My starting code looks like:
function showSpan() {
var linkID = document.getElementById(this.id);
var classList = linkID.getElementsByTagName('span');
var divID = classList[0];
divID.style.display = "block";
return false;
} // function
with a similar function for hideSpan(),
Ultimately I would like to add these event handlers in the initialisation phase, which is why I have used a parameterless function.
Whenever I try this, I get an error that this.id does not exist.
How can I attach these event handlers?
John Rostron
<a id="L1" href="#" onclick="return showSpan();" onblur="return hideSpan();"><span> ... </span></a>
The page is styled so that hovering over the link displays the contents of the hidden <span> as a block without any javascript. I want this to work (that is display the span as a block) when the user tabs onto a link (and presses Return/Enter). When the user tabs away, it should hide the <span>.
My starting code looks like:
function showSpan() {
var linkID = document.getElementById(this.id);
var classList = linkID.getElementsByTagName('span');
var divID = classList[0];
divID.style.display = "block";
return false;
} // function
with a similar function for hideSpan(),
Ultimately I would like to add these event handlers in the initialisation phase, which is why I have used a parameterless function.
Whenever I try this, I get an error that this.id does not exist.
How can I attach these event handlers?
John Rostron