2

Does anyone have a clue on how I can solve this please? Answer below doesn't work.

I googled this question and found lots of answers but not suited to my problem.

I am trying to make a button call multiple functions (2 to be exact):

JS

  $(window).load(function(){
  $(function() { 
    $(".btn").click(function() { 
        html2canvas($(this).next(), {
            onrendered: function(canvas) {
                theCanvas = canvas;
                document.body.appendChild(canvas);

                canvas.toBlob(function(blob) {
          saveAs(blob, "Dashboard.png"); 
        });
            }
        });
    });
}); 
});
  $('.btn').on('click', function(){
   $('canvas').appendTo('#here');  // appendTo -> selector
});

HTML

<a href="#" class="btn">Click</a>

I've tried the following: 1. Call two functions from same onclick 2. Can i append an already existing div to another already existing div?

Which really sums up every other answer.

Any suggestions?

1 Answer 1

4
$(function(){
    $('.btn').on('click'(function(){
        callFunction1();
        callFunction2();
    });
});

function callFunction1(){
   $('#yourDivId').appendTo('#yourOtherDivId');
   console.log("what should function 1 do?");
}

function callFunction2(){
   console.log("What should function 2 do?");
}
Sign up to request clarification or add additional context in comments.

2 Comments

So do I add 'callFunction1' like this? callFunction1(){ $('.btnSave2').on('click', function(){ $('canvas').appendTo('#here'); // appendTo -> selector }); };
@SteveGates nope, callFunction1 and callFunction2 are example names I used. You have to replace with your function calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.