0

I want to add a trigger click on page load, so am having a trigger function:

$("li.vjs-menu-item").eq(2).trigger('click');

It's working fine on Desktops, but it doesn't work with touch devices like Andriod and iPhones. I tried to add touchstart on the same click event:

$("li.vjs-menu-item").eq(2).trigger('touchstart click');

But it doesn't make any sense, so I want to know what is the equivalent trigger call for touch events ?

Kaspar Lee
  • 5,446
  • 4
  • 31
  • 54
Jothi Kannan
  • 3,320
  • 6
  • 40
  • 77

2 Answers2

0

This can be accomplished with pure javascript:

var link = document.getElementById( 'link_to_click' ),
    event = document.createEvent( 'HTMLEvents' );

event.initEvent( 'click', true, true );
link.dispatchEvent( event );

Check this answer: https://stackoverflow.com/a/14669335/4063816

Community
  • 1
  • 1
p. leo
  • 48
  • 1
  • 1
  • 7
0

Have you tried touchend event? Also if that does not work you can try a work around by triggering focusout event.

Krishna
  • 5,194
  • 2
  • 28
  • 33