-2
<input type="button" value="Scramble" onClick="scramble();">
<p id="scramble">
</p>

The button that I have right now will generate a scramble but I would like it to also create two buttons. One that reveals the solution and the other that reveals a hint.

  • 1
    You might want to visit [How to ask on Stackoverflow](http://stackoverflow.com/help/how-to-ask) – Yousaf Feb 11 '17 at 17:53

1 Answers1

1

Please check other stacks first next time. Javascript: onclick/onsubmit for dynamically created button

Code

 <button onclick="isPressed()"> Press here</button>
<script> 
function isPressed(){
  var button = document.createElement('button');
  button.innerHTML = 'hint';
  document.body.appendChild(button);
  
    button.onclick = function(){
    alert('I am a hint!');return false;
  };
  
  var button2 = document.createElement('button');
    button2.innerHTML = 'solution!';
  document.body.appendChild(button2);
    button2.onclick = function(){
    alert('I am a sulution');return false;
  };
};
</script>
Community
  • 1
  • 1
Nico
  • 154
  • 1
  • 16