Does jQuery mouseup work on touch devices?

I could not find the answer, so I ask here. I currently do not have any touch devices, so I can not test it.

The following code hides all subcontainers in the container if it is clicked outside.

$(document).mouseup(function(e) { var container = $('#container'); if (!container.is(e.target) // if the target of the click isn't the container... && container.has(e.target).length === 0) // ... nor a descendant of the container { $('.subcontainer').hide(); } }); 

Does this work on touch devices or is there any equivalent mouseup for touch devices?

+8
jquery mouseup
source share
1 answer

No, that will not work. But there is a touchstart and touchend .

 $(document).bind( "mouseup touchend", function(e){ var container = $('#container'); if (!container.is(e.target) // if the target of the click isn't the container... && container.has(e.target).length === 0) // ... nor a descendant of the container { $('.subcontainer').hide(); } }); 
+16
source share

All Articles