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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:19:45+00:00 2026-06-02T20:19:45+00:00

I have created the following code http://jsfiddle.net/N65yS/41/ .. My problem is this.. When I

  • 0

I have created the following code
http://jsfiddle.net/N65yS/41/
..

My problem is this..
When I click on the ‘draw’ button ,for the first time it is working..Succeding clicks on the button is not calling the listener.
Why is this happening…
Is there any problem with event listeners and object literals..
Why is this strange behaviour happening?

I have given proper comments and some helpful alert messages (and please dont down vote for the alert messages :P)..

  • 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-02T20:19:46+00:00Added an answer on June 2, 2026 at 8:19 pm

    At this line

    document.body.innerHTML += elm;
    

    you are adding another element to the document. However! What this line does is

    document.body.innerHTML = document.body.innerHTML + elm;
    

    The browser takes the whole HTML markup of the document and adds the markup of elm to it. Then, when you assign to document.body.innerHTML, the browser removes all the elements from the document, then parses the expression document.body.innerHTML + elm and adds all the elements from it to the document again.

    This means that not only your new element elm is added, but every other element in the document body is first removed and then a new instance of it is added to the document again. During this process, all event listeners are lost! In fact, in old IE these detached event listeners even caused memory leaks.

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

Sidebar

Related Questions

I have the following code which is created with a datalist control: http://jsfiddle.net/vmE2E/1/ But
I have the following code: <html> <head> <script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script> <script> FB.Event.subscribe('edge.create', function(response) { alert('TEST');
Take a look at the following fiddle: http://jsfiddle.net/DNhAk/14/ When you have an image with
Hi all I have created layout using following code <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
i have created a popup window using the following code in javascript; window.open(http://google.com, myWindow,
I have created custom controller by following http://code.google.com/apis/maps/documentation/javascript/controls.html Is there any way to remove
I have the following fiddle here: http://jsfiddle.net/9jN8L/ The idea is that sidebar will be
this code http://jsfiddle.net/minagabriel/5MQ77/ var flowShadeBigArray =[] ; var x = [7, 411, 780] var
All, I have the following code: $context = stream_context_create(array( 'http' => array( 'timeout' =>
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp

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.