/    Sign up×
Community /Pin to ProfileBookmark

onmouseover event

Why does this code not produce a dropdown list when onmouseover happens?

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 TRANSITIONAL//EN”>
<html>

<head>
<style type=”text/css”>

div.dg
{

border:2px solid white;
display:none;
}

a
{
width: 100px;
text-align:center;
background-color:red;
color:white;
font-size:16px;
display:block;

}

</style>

</head>

<body>

<div>
<a id=”kj” href=”kkjklj.com” onmouseover=”this.parentNode.childNodes[1].style.display=’inline’;”
onmouseout=”this.parentNode.childNodes[1].style.display=’none’;”>kjlj</a>
<div class=”dg”>
<a href=”kjlj.com”>lkjefee</a>
<a href=”ehfueh.com”>fheufheuih</a>
</div>
</div>

</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorOct 18.2011 — 
  • 1. [B]childNodes[][/B] is inconsistent among browsers. Some browsers, like Mozilla, count all the [I]possible[/I] text nodes (the "gaps" between the tags) as childNodes, others, like IE, count only some of them or none. As a result childNodes[1] might designate different elements, according to the browser. Use [B]getElementsByTagName()[/B] instead.


  • 2. A DIV element is a block level element, thus it can not have the display inline. You should use the value: [B]block[/B]


  • Is this what you want?
    <i>
    </i>&lt;div&gt;
    &lt;a id="kj" href="kkjklj.com" onmouseover="this.parentNode.getElementsByTagName('div')[0].style.display='block';"
    onmouseout="this.parentNode.getElementsByTagName('div')[0].style.display='none';"&gt;kjlj&lt;/a&gt;
    &lt;div class="dg"&gt;
    &lt;a href="kjlj.com"&gt;lkjefee&lt;/a&gt;
    &lt;a href="ehfueh.com"&gt;fheufheuih&lt;/a&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    Copy linkTweet thisAlerts:
    @jmu2101authorOct 18.2011 — i didn't know that, thank you very much. Yes that is the code i was trying to write!
    ×

    Success!

    Help @jmu2101 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...