Link to home
Start Free TrialLog in
Avatar of rafique12
rafique12

asked on

jQuery touch to .Open and .Close

Hi people,

Does anyone know how to replicate the hover function on touch devices?

I am able to open a dropdown menu with touch but I can seem to get it to close when touched!

<script>
<-- Below opens the dropdown -->
jQuery('.dropdown-toggle').on('touchstart', function(e) {		 
	e.stopPropagation();
   var dropdown = jQuery(this).open(".dropdown-menu");

<-- Now I am trying to close on touch --> 
   jQuery('.dropdown-toggle').on('touchstart', function(e) {		 
	e.stopPropagation();
   var dropdown = jQuery(this).removeclass(".open");
   });
});
</script>

Open in new window


Any able to point me in the right direction will be much appreciated...
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

I don't work with mobile, but I have seen things like this:

$("a").live("touchstart", function(e) {
  $(this).trigger("hover");
});


Cd&
SOLUTION
Avatar of mcnute
mcnute
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rafique12
rafique12

ASKER

Thanks for the contributions guys!

But I've not been able to use touch to close using either of the above methods^
Then maybe you should post a link instead of expecting a solution when all you have given us is a fragment of code with no context.

Cd&
Same as JQuery library are you sure that you have jQuery mobile library loaded to the site too (http://jquerymobile.com/)?
^The link is dead, but yes I have it loaded.

Thanks for the response though!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for not closing this sooner