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

  • SEARCH
  • Home
  • 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 873711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:59:03+00:00 2026-05-15T10:59:03+00:00

[Update:] This question is related to: what does jQuery’s click() do? jQuery's click() is

  • 0

[Update:] This question is related to: what does jQuery’s click() do?

jQuery's click() is not clicking?

The following code:

  <div id="oneDiv">
    some content
  </div>
  
  <p>
    <a href="http://www.google.com" id="clickme">Click Me</a>
  </p>

        [ ... ]

  onload = function() { 

    $('#clickme').click(function() {
      $('#oneDiv').css({border: '6px dotted #07d'})
    });
    
    document.getElementById('clickme').onclick = function() {
      document.getElementById('oneDiv').style.color = 'green';
    }
    
    document.getElementById('clickme').addEventListener("click", function() {
      document.getElementById('oneDiv').style.background = '#ffc';
    }, false);  // bubbling phase
    
    
    setTimeout(function() {
      $('#clickme').click();
    }, 3000);

  }

If you click on the link, then the browser will

  1. change border to 6px dotted blue
  2. change text inside the div to be green
  3. change background of div to offwhite
  4. go to http://www.google.com

but if you wait and let the setTimeout()’s function to kick in, then it will only do the

$('#clickme').click(function() { })  
onclick = function() { ... }

it will not do the addEventListener one, and it will not follow the link. (IE 8 won’t allow addEventListener by the way)

So is it true? jQuery’s click(), which is the same as trigger('click') will only fire off event handlers registered through itself and the DOM level 0 event handler?

  • 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-15T10:59:04+00:00Added an answer on May 15, 2026 at 10:59 am

    jQuery is supposed to give you some help for selectors and events, but you mix it with straight javascript. I think it will be better to use jQuery format only so :

    _replace

    document.getElementById('clickme').onclick
    

    by

    $('#clickme').click(function {...});
    

    _ replace

    addEventListener("click"
    

    _ by

    live("click") or bind("click")
    

    (see jQuery documentation for the difference).

    _ Finally :

    document.getElementById('oneDiv').style.background = '#ffc';
    

    _ by

    $('#oneDiv').css('background-color','#ffc');
    

    also :

    change onload by $(window).load(function() {….});

    Tell us after if there is still a problem, but I advise you you read a good tutorial if you really want to get into jQuery and do powerful stuff 😉

    Edit : This should definitely works :

    $(window).load(function() {
                $('#clickme').click(function() {
                $('#oneDiv').css({border: '6px dotted #07d'});
                $('#oneDiv').css('color','green');
                $('#oneDiv').css('background-color','#ffc');})
    
                setTimeout(function() {
                    $('#clickme').click();
                }, 3000);
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.