Handle tap event
Description
The following code shows how to handle tap event.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.6.4.js'></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css">
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!--from ww w . j a va 2 s . c o m-->
$("div:jqmData(role='collapsible')").each(function(){
bindEventTouch($(this));
});
function bindEventTouch(element) {
element.bind('tap', function(event, ui) {
if(element.hasClass('ui-collapsible-collapsed')) {
alert(element.attr('id')+' is closed');
} else {
alert(element.attr('id')+' is open');
}
});
}
});//]]>
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="content">
<div data-role="collapsible" id="number1">
<h3>Header #1</h3>
<p>I'm Header #1</p>
</div>
<br />
<div data-role="collapsible" data-collapsed="false" id="number2">
<h3>Header #2</h3>
<p>I'm Header #2</p>
</div>
</div>
</div>
</body>
</html>