Reputation: 18918
I had a div with links that underlined once you hover over them. I added an onmouseover
JS event to the div and now the hyperlinks no longer underline when I hover over them, but instead whatever action I put into the onmouseover
event gets executed instead.
CODE from function:
function addPlus(elementId)
{
if(typeof addPlus.backup == 'undefined')
addPlus.backup = document.getElementById(elementId).innerHTML;
if(full)
{
document.getElementById(elementId).innerHTML = plusCode + addPlus.backup;
return backup;
}
else
return snippet;
}
div code:
<div class="nav_bar" id="navbar1" onmouseover="addPlus('navbar1')" onmouseout="removePlus('navbar1')">
EDIT: I've tried return true;
, return Boolean(true);
, and return new Boolean(true);
, in an attempt to "return true" as Chad suggested. None of them work. Sorry, I really don't know what to do; I'm new to Javascript.
EDIT 2: Darn it, I just realized Chad meant that I return true in the div tag. So now I have <div class="nav_bar" id="navbar1" onmouseover="addPlus('navbar1');return true" onmouseout="removePlus('navbar1')">
, but it unfortunately still doesn't work.
Upvotes: 2
Views: 2003
Reputation: 2822
If you don't want for js event to fire you should stop event propogation when mouse enters <a>
. Try adding onmouseover event handler for each hyperlink with return false - <a onmouseover="return false" ...
- that should help.
Upvotes: 1
Reputation: 303520
onmouseover
handler in HTML or JavaScript to handle the link underline (instead of properly using addEventListener
), and then you are overwriting this handler. It's hard to guess what might be wrong without more information. Supply a code example for more help.Upvotes: 0
Reputation: 2946
for the event to propagate you need to return true from your onmouseover handler.
Upvotes: 0