Here after clicking on the link onmouseout event should be called.I'm very poor in Javascript & need help in this
Required something like this
when I enter into the block of reporting,& click on subscribe then mouseout event occurs.The same functionality I want here
My code
<style>
.helpLink {
position:relative;
}
.videoPanel {
display:none;
width:160px;
height:120px;
background:#EEE;
border:1px solid #CCC;
position:absolute;
left:-160px;
z-index:10;
}
</style>
<apex:outputLink styleClass="helpLink" onmouseover="$('{!$Component.Foo}').style.display = 'block';" title="help" onmouseout="$('{!$Component.Foo}').style.display = 'none';" >
<apex:image value="/s.gif" styleClass="helpIcon" />
</apex:outputLink>
<apex:outputPanel id="Foo" styleClass="video" title="help" >
<a href="google.com" target="_blank" onmouseout="$('{!$Component.Foo}').style.display = 'none';">link</a>
<a href="youtube.com" target="_blank" onmouseout="$('{!$Component.Foo}').style.display = 'none';">Video</a>
</apex:outputPanel>
Best Answer
There are 2 reasons that your current
onMouseOut
andonMouseOver
code is not working:$Component.<componentName>
syntax only gives you the Component's Id, but does not prefix it with a `#' sign, which is the selector for getting a DOM element by its Id.$(selector).show()
,.hide()
, or.toggle()
methods. If you explicitly want to set thedisplay
property, then use$(selector).css('display','block')
<apex:outputLink id="Foo" value="http://apple.com">
, the generated DOM might be something like<a href="http://apple.com" id="j_id0:Foo"/>
. So the best practice for accessing DOM elements by Id with jQuery in Visualforce is to do this:jQuery('[id$=<visualforceId>]').hide()
, or in your case,jQuery('[id$=Foo]').hide()
;So, with these in mind, here is how you can adjust your 2 handlers: