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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:56:28+00:00 2026-06-14T19:56:28+00:00

I have a number within a span element that changes often. I want to

  • 0

I have a number within a span element that changes often. I want to be able to detect any changes in this number and store that number in a variable.

so far I have tried this:

var x = $('#mynum').text();

This code however doesn’t detect any changes – it only gets the value when the page first loads.

I have also tried this:

$('#mynum').bind('change',function(){

alert('wahoo!');   });

However I cannot get it to even make the alert.

What would be the best way to detect the changes and store the number in a variable whenever it does change?

  • 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-06-14T19:56:30+00:00Added an answer on June 14, 2026 at 7:56 pm

    Change event only happens from the browser on the blurring of form fields. If you’re changing the value of a span from your script, you need to $('#mynum').trigger('change');. Then your bind will work, assuming the element #mynum was in the DOM when the bind was set. If not, bind to a consistent parent element and delegate it with on:

    $('#myParentNode').on('change','#mynum', function() {
        alert('wahooo!');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big, complex MATLAB program. Somewhere within that, the number 0 is
I have a number of draggable images that I want to clone and then
I have a simple span like so <span class=action removeAction>Remove</span> This span is within
I have this HTML code: <div> 756 <span></span> </div> Using JavaScript I want to
I have a number of associations within my LinqToSql designer file that I have
I have a number of buttons within a grid, that all change size based
I have an element in javascript like follows: <span>280ms</span> I want to extract 280
I have a span tag and that holds some n number of span tags..
I have a number of existing methods within a controller. Each one of those
I have number of line breaks in a string. But I only want it

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.