Jquery click and hover & show/hide function oddness?

You could reduce the body of your showTooltip() function to.

You could reduce the body of your showTooltip() function to... function showTooltip(e){ $(e).toggle(); } You could also lose the $() wrapping, if you are sure that a jQuery object will always be passed. However, it doesn't hurt to wrap it again, and it gives you the flexibility of passing a selector or native DOM element. Documentation.

Also, for explictly checking if an element is hidden, you can use... element. Is(':hidden') Documentation. Keep in mind that elements with visibility: hidden or opacity: 0 are considered visible by this selector.

You're right. Updated post above – julie p Apr 8 at 14:38.

Function showTooltip(e){ $(e). Is(':hidden')? $(e).show() : $(e).hide(); return false; } $('#nav-about a').

Hover( function(){ showTooltip('#tooltip-about'); }, function(){ showTooltip('#tooltip-about'); } ).

Try this: function showTooltip(e){ if( $(e). Css('display') =="none" ) { $(e). Css('display', ''); } else { $(e).

Css('display', 'none'); } return false; }.

The problem is that you can't click without also hovering over the element. So the tooltip is shown by the hover event then the click event closes it. You would need some way to determine whether the user is using a device that allows them to hover and only bind the appropriate events.

You can probably use something similar to this: function isiPhone(){ return ( (navigator.platform. IndexOf("iPhone")! = -1) || (navigator.platform.

IndexOf("iPod")! = -1) || (navigator.platform. IndexOf("iPad")!

= -1) ); } if (isiPhone()) { $('#nav-about a'). Click(showTooltip) else $('#nav-about a'). Hover(showTooltip) function showTooltip(e) { e.preventDefault(); $('#tooltip-about').toggle(); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions