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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:41:26+00:00 2026-05-25T00:41:26+00:00

The following code only displays the last .text upadate. It works as expected with

  • 0

The following code only displays the last .text upadate. It works as expected with alert(),

$(‘#jTest')
.bind(‘click’,function(event) {
alert(‘Hello!’);
})
.bind(‘click’,function(event) {
alert(‘Hello again!’);
})
.bind(‘click’,function(event) {
alert(‘Hello yet again!’);
});

How can I craft my attempt, to behave as the alert?

$('#jTest')

  .bind('click',function(event){
    $(this).text("1st Click").css("fontSize","2em");


})

  .bind('click',function(event){
    $(this).text("2nd Click").css("fontSize","4em");


})

.bind('click',function(event){
    $(this).text("3rd Click").css("fontSize","6em");


});






<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

</head>
<body>
  <div id = "jTest"><p>Test Data String</p></div>
</body>
</html>
  • 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-25T00:41:26+00:00Added an answer on May 25, 2026 at 12:41 am

    If you bind event handlers to an element, then all of them are executed when the event occurs. You see the three alerts one after another, because alert is blocking. I.e. JavaScript continuous executing after you click ok.

    Changing the text or CSS is not blocking, but it is changed three times. It is just so fast that you don’t see it.

    If you want to change the text on alternate clicks (or execute different callbacks in general), you can use .toggle [docs]:

    $('#jTest').toggle(function(event){
        $(this).text("1st Click").css("fontSize","2em");     
    }, function(event){
        $(this).text("2nd Click").css("fontSize","4em");  
    }, function(event){
        $(this).text("3rd Click").css("fontSize","6em");
    });
    

    DEMO

    This would cycle over the event handlers (you did not mention what you actually want to do).

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

Sidebar

Related Questions

The following code displays only the last record from the database. How to display
I used following code, but it displays only 2 digit of ISO country name.
Does anybody know why the following code only has effect in FF? $(document).ready(function() {
This post concerns only IE. The last line of the following code is causing
The following code is only grabbing the value of the last result in the
I have the following html code: <input type=text id=theInput value=/> <a href=# id=theLink>Click me</a>
What should I do to marshal an hash of arrays? The following code only
One recommends me the following code apparently only in .zshrc without explaining its purpose
In this thread some one commented that the following code should only be used
When I compile the following code, I only see the error during Run-time which

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.