0

I can't make this code work properly,

$(document).ready(function() {
    $('.hover').bind('touchstart touchend', function(e) {
    e.preventDefault();
    $(this).toggleClass('hover_effect');
});

can you please have a look at my JSFiddle test script?

Thanks!

Community
  • 1
  • 1
user3648203
  • 55
  • 1
  • 8

1 Answers1

0

You are binding 'touchstart touchend' to '.hover', however there is no element having class 'hover'. Try bind to 'p' like this:

$(document).ready(function() {
    $('p').bind('touchstart touchend', function(e) {
        e.preventDefault();
        $(this).toggleClass('hover_effect');
    });
});

or a more explicit selector other than just 'p'.

Also, your jsfiddle did not load jQuery lib.

http://jsfiddle.net/8PxXL/

Edward
  • 1,914
  • 13
  • 26