Tonzkie
Tonzkie

Reputation: 549

Trigger code not working Uncaught error on Jquery

I'm trying to trigger the first anchor of the ul but somehow my jQuery gives off this error Uncaught TypeError: Cannot read property 'type' of undefined. I have no idea why it is doing this would appreciate any help this is my code.

<span style="cursor:pointer;color:#363636;" onclick="popall()">Click to zoom</span>

Above is event handler below is my js.

<script type="text/javascript">
var j = jQuery.noConflict();
function popall(){
j('#lightgallery a:first').trigger();
}

I'm trying to target this.

<ul id="lightbox"><li><a . . . . . . .  </ul>

my jquery is 1.8.2 min

Upvotes: 0

Views: 211

Answers (3)

Parfait
Parfait

Reputation: 1750

.trigger( eventType [, extraParameters ] )

eventType
Type: String
A string containing a JavaScript event type, such as click or submit.

extraParameters
Type: Array or PlainObject
Additional parameters to pass along to the event handler.

eventType is missing

Upvotes: 1

S. S. Rawat
S. S. Rawat

Reputation: 6121

You should define the which event can be handled

j('#lightgallery a:first').trigger('click');

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388416

You need to pass the event name to be triggered to .trigger() like click

j('#lightgallery a:first').trigger('click');

Upvotes: 5

Related Questions