0

I'm trying to trigger a click on one of the navigation dots from another DOM element, but I can't seem to do it a la the following:

$('li.dot')[0].click();

Any help is appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

EDIT: Sorry I don't usually use jQuery. I forgot you need to use first, or first-child, or something of the type to get the node from the jQuery object, not use el[0].

$('li.dot').first().trigger('click');
thesublimeobject
  • 1,393
  • 1
  • 17
  • 22
  • You know you can do `$(li.dot:first')` right? and when `.click()` is called without arguments, it is a shortcut for `.trigger("click")`. – callback Feb 16 '17 at 14:31
  • I changed my answer, as I realized right as you were voting. I don't use jQuery as often any more. :) – thesublimeobject Feb 16 '17 at 14:32