/    Sign up×
Community /Pin to ProfileBookmark

onmouseover with Div tag containing user controls

I’ve got a use control box in the upper left corner of my app that contains 3 user controls (two text boxes, one combobox). I’m trying to get this control to fade when the mouse is not hovering over it and to be fully visible when the mouse is hovering over it.

I can connect to the <div>’s onmouseover and onmouseout events just fine and manipulate the <div>’s opacity easily as well. The problem comes when I’m hovering inside the <div>, and then hover over one of the user controls contained within the <div>, the control box fades as the user control’s onmouseover is fired which in turn fires the control <div>’s onmouseout.

In short: when hovering over controlsPane, I want the div to be completely visible, when the mouse is not hovering over the controlsPane it should be transparent.

Simplified HTML:

[CODE]
<div id=”controlsPane”>
<div><input id=”InputFeet”></input> ft
</div>
<div><input id=”InputMeters”></input> m
</div>
<div><input id=”InputDatum”></input>
</div>
</div>[/CODE]

I’m using the dojo toolkit here, but the issue exists in plain JS, so… for what it’s worth, here’s my dojo event code:

[CODE]
ControlMouseOver = dojo.connect(controlsPane, “onmouseover”, function(event){
if(event.target == controlsPane) dojo.style(controlsPane,{opacity:”1″});
dojo.stopEvent(event);
});

ControlMouseOut = dojo.connect(controlsPane, “onmouseout”, function(event){
if(event.target == controlsPane) dojo.style(controlsPane,{opacity:”0.3″});
dojo.stopEvent(event);
});[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@jamesbcox1980Nov 09.2009 — Why don't you use jQuery?

with jQuery, you can simply say onmouseover="this.fadeIn('fast')" or onmouseover="this.slideDown('fast')" to get a fading effect in or sliding down effect respectively. I think you can give it an opacity, can when you fadeOut, it will match that opacity. I haven't tested this, but you might give it a try.
×

Success!

Help @Vamirr 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,
)...