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

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

The Archive Base Latest Questions

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

in this code: $(a).live(click, function(e) { e.preventDefault(); setTimeout(function () { $.get( someOtherUrl, {someVariable: someValue},

  • 0

in this code:

$("a").live("click", function(e) {
    e.preventDefault();
    setTimeout(function () {
        $.get(
            "someOtherUrl",
            {someVariable: "someValue"},
            function(result) {
                $(".result").html(render(result));
            }
        );
    }, 1000);
    $('a').live("touchmove", function(e) {clearTimeout()});
});

I want to stop the timeout when the user moves his finger on the screen. The thing is that clearTimeout() doesn’t work because it is not linked to the timeout. How would I name the timeout and clear it quickly?
Am I using the right method?

  • 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-26T00:28:12+00:00Added an answer on May 26, 2026 at 12:28 am

    Save the return value from “setTimeout()” in a variable, and then pass that value to “clearTimeout()” to clear it.

    $("a").live("click", function(e) {
        e.preventDefault();
        var t = setTimeout(function () {
    
                   $.get(
                         "someOtherUrl",
                         {someVariable: "someValue"},
                         function(result) {
                         $(".result").html(render(result));
                         }
                         );
    
        }, 1000);
        $('a').live("touchmove", function(e) {clearTimeout(t);});
    });
    

    Now I would actually write that quite differently; as it is, you’re adding a redundant “touchmove” handler on every click. Maybe something like this:

    function setupAnchorClicks() {
      var timer = null;
      $("a").live("click", function(e) {
        e.preventDefault();
    
        timer = setTimeout(function() {
           // ...
        }, 1000);
    
      }).live("touchmove", function() {
        clearTimeout(timer);
      });
    }
    
    setupAnchorClicks();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: $('.be-delete').live('click', function(e){ e.preventDefault(); var object =$(this); var url = $(this).attr('href');
I have this jQuery code: $(div.note a).live(click, function(e) { e.preventDefault(); alert('test'); }); <div id=note_list>
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
$(.overlay).lightbox(); $('.overlay').live('click', function(e){ e.preventDefault(); var url = base_url + 'ajax/getcolorboxhotel'; var data = $(this).next('span').text();
I'm implementing Simplemodal in an application of mine using this code: $(.dialog-link).live('click', function(e) {
I have this piece of code $('ul.fonts li', '#wizard').live('click', function(e){ $('ul.fonts li', '#wizard').removeClass('selected'); $(this).addClass('selected');
I have some JQuery Code as follows: $(#sh-zone-button-cart-menu).live(click, function(event) { event.preventDefault(); $(#sh-zone-cart-menu).toggle(0, function(){ if($(this).is(:visible)){
In this function, when I use it I get error on the whole code
Why in this code after click on button get error: http://jsfiddle.net/FyUgH/ {error: Shell form

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.