A
A
Andrey Shamov2011-06-29 15:07:07
JavaScript
Andrey Shamov, 2011-06-29 15:07:07

Onclick event in web applications in desktop and iOS browsers?

In the iOS Safari browser, the onClick event fires after ~400ms (you can check it here ). To avoid this, you can use the touchstart event.
Is it possible to somehow determine for all elements on the page if it has an onClick handler? then replace onClick with touchstart. Better if it's in jQuery.

Now I explicitly indicate why I need to replace the handlers

$('.sidebar_item').live('touchstart', function(e) {<br>
  $(this).click();<br>
  e.preventDefault();<br>
});<br>

Here we need the same thing, but for all elements. Please tell me how to do it.

Tried like this:
$('*').each(function() {<br>
  var me = $(this);<br>
  if(me.click != null) {<br>
    // но me.click есть для всех элементов<br>
  }<br>
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
ertaquo, 2011-06-29
@ertaquo

Maybe so?

$('*[onclick]').live('touchstart', function(e) {
  $(this).trigger('click');
  e.preventDefault();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question