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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:31:42+00:00 2026-06-03T01:31:42+00:00

Trying to solve this one for a long time, jsfiddle wont re-produce this code

  • 0

Trying to solve this one for a long time, jsfiddle wont re-produce this code to show the problem.

‘click’ event is getting triggered twice on the element, which was previously processed with hide() and show(‘slide’).

Doesn’t happen when using show() or fadeIn(1000);
Doesn’t happen when moving event handler inside $(document).ready(){}.

I have to use this exact structure with <script></script> inside of the element.
No way I can change it.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link href='/styles/jquery-ui-1.8.18.custom.css' rel='stylesheet' type='text/css'>
<script src='/js/jquery.js' type='text/javascript'></script>
<script src='/js/jquery-ui-1.8.18.custom.js' type='text/javascript'></script>
<script type='text/javascript'>
  $(document).ready(function() {
    $('#container').hide().delay(750).show('slide');
  });
</script>
</head>
<body>

<div id='container'>
  <div class='download'>Download</div>
  <script type='text/javascript' id='js4container'>
    $('.download').click(function() {
      alert('Trigger');
    });
  </script>
</div>

</body>
</html>

I understand that show() does launch the inside of <script></script> once more, binding same event.

Is there a workaround? =)

Please help. Thanks.

  • 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-03T01:31:45+00:00Added an answer on June 3, 2026 at 1:31 am

    You can always use .one(), which only fires on the first event. But you may still end up with multiple .one() triggers if you don’t click between each call to .one():

    $('.download').one('click', function() {
         alert('Trigger');
    });
    

    Or, remove the handler(s) each time with .off():

    $('.download').off('click').on('click', function() {
         alert('Trigger');
    });
    

    This can also be written in the delegate syntax attached to #container or body:

    $('body').off('click', '.download').on('click', '.download', function() {
         alert('Trigger');
    });
    

    Demo: http://jsfiddle.net/QnfMZ/1/

    The reason this happens is that jQuery UI uses helper elements to create transitions. They maintain correct layout, etc while the animation is occuring. These helper elements are created using clone() which copies the html of the element, which in your case means it copies the script, too. The script then runs, adding a second handler. After the transition is done, the helper clone is deleted, but you are still left with an extra handler.

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

Sidebar

Related Questions

I've been trying to solve this issue for a long time, and nothing seems
I'm trying to solve this problem, its not a homework question, its just code
I am trying to solve this exponentiation problem . Here is the code that
I've been having this problem for a long time now and I cannot solve
Trying to solve this problem . I would like to learn how the bootstrapper
I'm trying to solve this flickering problem on the iphone (open gl es game).
I am trying to solve this problem. I have a series of SELECT statements
I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html . For the given example, they
I've been trying to solve this problem for a number of days now but
I have been trying to solve this problem for a while, but couldn't with

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.