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 6014371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:40:57+00:00 2026-05-23T02:40:57+00:00

I observed when I put the ready event the function works but as I

  • 0

I observed when I put the ready event the function works but as I remove it It does not..

Works.

<script type="text/javascript">
    $(document).ready( function() {
        $('.clicky').click( function() {
            alert("TEst10");
            $(this).addClass('clicked');
            alert("TEst10");
            setTimeout( function() {
                $(this).removeClass('clicked');
            }, 1000 );
        });
    });
</script>

Not work

<script type="text/javascript">
    $('.clicky').click( function() {
        alert("TEst10");
        $(this).addClass('clicked');
        alert("TEst10");
        setTimeout( function() {
            $(this).removeClass('clicked');
        }, 1000 );
    });
</script>

Why the second one does not work?

  • 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-23T02:40:58+00:00Added an answer on May 23, 2026 at 2:40 am

    Because element with a class clicky isn’t in the DOM structure when your second code gets called.

    The first one works because you wrapped the code in document.ready function which gets invoked once the DOM is ready.

    If you want to make the second code work just put the code in the script tag after the definition of element with class clicky, preferably put the script at the end of the body tag.

    But why not just use document.ready ?

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

Sidebar

Related Questions

I have observed that, very infrequently, Internet Explorer (7 or 8, it does not
I have a view (actually, it's a table valued function, but the observed behavior
I have the following prototype JavaScript code Event.observe( window, 'load', function() { Event.observe( 'agreement',
This is a common question, but the explanations found so far and observed behaviour
IE is causing problems on totally blank space (not merely but totally). Then when
Trying to put in field pagar the calculated value of precio * 15% but
I want to implement an Observer of a Model class which does not change
I have a console project, but now I need to put an user interface
Im using this Layout to put two ImageViews one next to the other, but
There is prototype js function: Event.observe(element, eventName, handler) here the element means element's ID.

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.