How to trigger a click on a link using jQuery

0 votes

I have a link:

<ul id="titleee" class="gallery">
  <li>
    <a href="#inline" rel="prettyPhoto">Talent</a>
  </li>
</ul>

and I am trying to trigger it by using:

$(document).ready(function() {
  $('#titleee').find('a').trigger('click');
});

But it doesn't work.

I've also tried: $('#titleee a').trigger('click');

Edit:

I actually need to trigger whatever get's called here <a href="#inline" rel="prettyPhoto">

Jun 10 in JQuery by gaurav
• 17,580 points
30 views

1 answer to this question.

0 votes

$( "#foo" ). trigger( "click" ); As of jQuery 1.3, . trigger() ed events bubble up the DOM tree; an event handler can stop the bubbling by returning false from the handler or calling 

To trigger handlers bound via jQuery without also triggering the native event, use .triggerHandler() instead.

When we define a custom event type using the .on() method, the second argument to .trigger() can become useful. For example, suppose we have bound a handler for the custom event to our element instead of the built-in click event as we did above:

1

2

3

4
$( "#foo" ).on( "custom", function( event, param1, param2 ) {

alert( param1 + "\n" + param2 );

});

$( "#foo").trigger( "custom", [ "Custom", "Event" ] );
answered Jun 10 by rajatha
• 7,040 points

Related Questions In JQuery

0 votes
1 answer

How to scroll to element from bottom to top with a nice animation using Jquery?

Hello @kartik, Assuming you have a button with ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,740 points
2,639 views
0 votes
0 answers

How to replace innerHTML of a div using jQuery?

How could I achieve the following: document.all.regTitle.innerHTML = ...READ MORE

May 31 in JQuery by Edureka
• 13,640 points
179 views
0 votes
1 answer

How to make a simple modal pop up form using jquery and html?

Create A Modal <button onclick="document.getElementById('id01').style.display='block'" class="w3-button">Open Modal</button> ... <div ...READ MORE

answered Jun 2 in JQuery by Edureka
• 13,640 points
118 views
0 votes
1 answer

How to implement a dynamic bootstrap 4 accordion, using Jquery

With this you can add dynamic accordion ...READ MORE

answered Jun 7 in JQuery by Edureka
• 13,640 points
202 views
0 votes
1 answer

How to trigger a click on a link using jQuery

If you are trying to trigger an ...READ MORE

answered Jun 3 in JQuery by Edureka
• 13,640 points
317 views
0 votes
1 answer

jQuery mouse click counter

You can use jQuery's toggleClass function for that: $(" ... ...READ MORE

answered Jun 16 in JQuery by rajatha
• 7,040 points
77 views
0 votes
0 answers

jQuery mouse click counter

I need to color a table in ...READ MORE

Aug 2 in Web Development by gaurav
• 17,580 points
6 views
0 votes
1 answer

TRIGGERS used in MySQL tables

The following TRIGGERS are allowed in MySQL:  BEFORE ...READ MORE

answered Aug 21, 2018 in Database by CodingByHeart77
• 3,720 points
234 views
0 votes
1 answer

How to trigger a click on a link using jQuery

Use the jQuery click() Method You can use ...READ MORE

answered Jun 10 in JQuery by rajatha
• 7,040 points
26 views
0 votes
1 answer

How to focus on a form input text field on page load using jQuery?

In this example the form input text ...READ MORE

answered Jun 21 in JQuery by rajatha
• 7,040 points
11 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP