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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:11:29+00:00 2026-05-29T12:11:29+00:00

I have a messaging function that can be called several times on the same

  • 0

I have a messaging function that can be called several times on the same page. Each time it’s called, a new message appears at the top of the screen and has a unique ID set by an incrementing global.

The general idea of the function is below:

var messageTimer = function(msgid, duration) {
  ...
  var interval = setInterval(
    function() {
    ...
    },
    duration
  )
};

In the code above, a new message is created and a timer applied. If the timer runs out, the message disappears. However, if the message is clicked on anywhere except the close button, the timer should stop and the message should stay until manually closed.

How do I find the interval ID of the message box clicked? There could be 3 other boxes simultaneously open.

$('body').on('click', '.msg', function() {

});

Since I only have a class to trigger the click by I’m thinking the only possible way to find this is to set an additional field to the ID of the message box? However this method seems unnecessary and messy.

  • 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-29T12:11:30+00:00Added an answer on May 29, 2026 at 12:11 pm

    I would set a data property on the message which stores the interval ID:

    var messageTimer = function(msgid, duration) {
      ...
      var interval = setInterval(
        function() {
        ...
        },
        duration
      );
      $("#" + msgid).data("i", interval);
    };
    

    Then recall it onclick of your message thingies:

    $('body').on('click', '.msg', function() {
        clearInterval(parseInt($(this).data("i"), 10));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that's called by a link which should check various checkboxes
I have a legacy C++ application that uses DDS for asynchronous communication/messaging. I need
I have a C# app that subscribes to a topic on our messaging system
I have a script that I only want to be running one time. If
I'm really hoping that someone can help. I have tomorrow to get this right
G'day All, A page that is created by a 3rd party they have the
I have a bunch of divs that the user can create and which represent
I have been messing around with Leaks trying to find which function is not
Suppose you have a messaging system built in PHP with a MySQL database backend,
I have been researching asynchronous messaging, and I like the way it elegantly deals

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.