语言

Menu
Sites
Language
taphold event is not working

Hi,

taphold event is not working in my web app. Its working in simulator but not in device.

$( "div.box" ).bind( "taphold", tapholdHandler );
 
  function tapholdHandler( event ){
    $( event.target ).addClass( "taphold" );
  }

Thanks in Advance.

 

响应

5 回复
konduri sai swathi

Hi,

It's working fine for me. I have tested it in device. What do you want to happen when taphold event is triggered on div with class "box" ?

can you share more of your code for clarity

Lakshmi Prathyusha

Hi Swathi,

What output you are getting ?

<style>
div.box {
    width: 3em;
    height: 3em;
    background-color: #108040;
  }
  div.box.taphold {
    background-color: #7ACEF4;
  }
</style>
<body>
 
<h3>Long press the square for 750 milliseconds to see the above code applied:</h3>
<div class="box"></div>
 
<script>
$(function(){
  $( "div.box" ).bind( "taphold", tapholdHandler );
 
  function tapholdHandler( event ){
    $( event.target ).addClass( "taphold" );
  }
});
</script>
 
</body>

 

konduri sai swathi

Hi,

Try the bewlo code :

$(document).ready(function(){
    $("div.box").bind("taphold",function(){
		$(this).css('background','#7ACEF4')
	});
});

And remove "div.box.taphold" style.

Lakshmi Prathyusha

I tried its not working. what output your getting ? When you tap on the box its changing the color ?

 

konduri sai swathi

Yea the color is changing. Add the code in main.js.