1

I was surprised to see that the disabled attribute for the button is ignored on the mobile version of the site. How to disable the button for touchstart / touchend events? <button ontouchend="alert();" disabled="disabled" style="touch-event: none">Test for touch</button>show alert() after touch and ignoring disabled attribute. I tried to apply touch-event: nonein style - nothing happened

UPD. Here is some code - its workable but it not fine for simple use

$("button").on("touchend", function()
{
    if($(this).is(":disabled") == false)
    alert(1)    
});  

2 Answers2

0

I faced the same issue and located this topic.

As long as I tried it, disabled property disabled onClick, yet doesn't disabled onTouchStart and onTouchEnd.

And actually, onTouchStart and onTouchEnd is not an official property for <button>. I guess that's why.

Pingolin
  • 3,161
  • 6
  • 25
  • 40
0

An alternative u could use css adding the touch-action: none property to the button container