views:

191

answers:

5

when the user puts his mouseover this object i want a message to pop up:

onmouseover="evt.target.setAttribute('opacity', '0.5'); $('#someDiv').show();" onmouseout="evt.target.setAttribute('opacity','1)'); $('#someDiv').hide();"

what exaclty does someDIv mean? where do put the text?

i am doing this and it is not showing the text at all. it is just changing the opacity

A: 

#someDiv is just a item with "someDiv" as ID (that's right on CSS or Javascript).

In this case, you are ""loading"" #somediv and then, showing it (using jquery) or hiding it (with mouse in or mouse out)

Jesus Rodriguez
im very very sorry to ask but how do i make some text appear?a
I__
You put the text inside of the div tags, so it would probably look like (in your HTML):<div id="someDiv">Hover Text Here</div>
bryan.taylor
+1  A: 

someDiv is simply the ID associated to an element.

Mike
im very very sorry to ask but how do i make some text appear?a
I__
A: 

#someDiv is the id of the element (div I believe) which you want to show. You would put your text or whatever you want to show in the element with id='someDiv'

bryan.taylor
im very very sorry to ask but how do i make some text appear?a
I__
>< can you fix your answer so it's not so obnoxious? Thanks :P
Aardvark
+4  A: 

'#someDiv' is a CSS3CSS selector which is semantically equivalent to getElementById('someDiv'), in that it will select the element with ID 'someDiv'. So:

document.getElementById('someDiv')

==

// bracket notation will return a DOM element
$("#someDiv")[0]

// leaving it out will return a jQuery object
$("#someDiv") 
karim79
karim thank youi very much but "can you just help me make this work"
I__
`#someDiv` isn't CSS3 selector - it's much older... ;)
Crozin
@Crozin - How far back does it go?
karim79
@karim79: it's existed since CSS was introduced.
BoltClock
@BoltClock - Well then, just goes to show that I know squat about CSS :(
karim79
+1  A: 

Like karim79 and others said, #someDiv selects an element with an id of "someDiv" So, to get this to work, you will also need to place an element somewhere in your HTML with this ID. Something like

<p id="someDiv">Your message</p>
Doug Hurst
great, where shoul dit be placed exactly/?
I__
It really doesn't matter just so long as it's somewhere in the <body> element. It sounds like you might be trying to make something like a tooltip, so you may want to look at jQuery tooltip examples, like these: http://www.1stwebdesigner.com/resources/stylish-jquery-tooltip-plugins-webdesign/
Doug Hurst
The reason I say the above is because if you want the #someDiv element to appear and hide on the mouse event, then that's relatively simple. If you want it to appear in a specific place like, say, at the mouse location, that's a bit more involved.
Doug Hurst