Skip to content Skip to sidebar Skip to footer

Append Dynamic Div Just Once And A Jsfiddle Issue

This code is doing everything I want the first time a table node is clicked (image is added etc). However, when a second node is clicked the choices appear again, but twice and so

Solution 1:

Is there a way for me to append the elements just once ?

Yes. Just put following line at the end of your function, so it'll work only once

img.onclick = function() {
    // other code
    img.onclick=null;
}

Example1.

Or maybe you want this for the button

var makeChart = function() {
    // other codedocument.getElementById('createChart').onclick=null;
}

Example2

Post a Comment for "Append Dynamic Div Just Once And A Jsfiddle Issue"