Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:28:24+00:00 2026-05-27T08:28:24+00:00

I have this code : <a href=javascript:void(0) id=0 class=hp_nav_label>0</a> <a href=javascript:void(0) id=1 class=hp_nav_label>1</a> <a

  • 0

I have this code :

<a href="javascript:void(0)" id="0" class="hp_nav_label">0</a>
<a href="javascript:void(0)" id="1" class="hp_nav_label">1</a>
<a href="javascript:void(0)" id="2" class="hp_nav_label">2</a>
<a href="javascript:void(0)" id="3" class="hp_nav_label">3</a>
<a href="javascript:void(0)" id="4" class="hp_nav_label">4</a>

$('.hp_nav_label').click(function() {
    alert($(this).attr('id'));
});

When I click on each link, I display its id.

Now, I’d like, on document ready, “handle” automatically the link with id=2, without “clicking” on it.

So, having a sort of emulation on that link. Is it possible with jQuery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:28:25+00:00Added an answer on May 27, 2026 at 8:28 am

    To trigger an event simply call the relevant event function in jQuery on the element, with no handler function defined, like this:

    $("#2").click();
    

    Or there is also trigger(), which accepts the event type as a parameter:

    $("#2").trigger('click');
    

    However it’s worth noting that Id attributes beginning with numbers are invalid, so you will most likely have to change your Ids for them to work properly.

    I’ve updated your fiddle to fix the IDs and show the above code working here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: HTML <div class=box_meteo> <div class=box_meteo_pulsanti> <a href=javascript:void(0); class=box_meteo_pulsante id=meteoButton1>Link</a> </div>
i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have this code : HTML: <a id=openDiv href=javascript:void(0);>Show</a><br /><br /> <div id=control style=display:none;>
I have this code : <a class=myLink href='http://www.website.it/'>Link</a> <script type=text/javascript> var stringToSend = ;
I have a string that looks like this: <td width=308>Services Needed: <a href=javascript:void(null); title=weekly
I have this html. <a class=link href=www.website.com?id=233253>test1</a> <a class=link href=www.website.com?id=456456>test2</a> How can I hide
I have an tag on my page that looks something like this: <a href=javascript:void();
Hi guys lets say I have the following html: <div class=owner> <div> <a href=javascript:void(0)
HI, I have this code for extracting the href and adding it to a
$(document).ready(function(){ $(a[href*='http://']:not([href*='+location.hostname+'])).attr(target,_blank); $(a[target!='_blank'][target!='_top']).click(function(){ $(#actualcontent).load($(this).attr(href)); window.location.hash=$(this).attr(href); return false; }); }); So I have this code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.