Home > database >  How do I make a <button> show a specific text in console.log when I click on the button?
How do I make a <button> show a specific text in console.log when I click on the button?

Time:12-07

I've been coding for a week and I'm stuck on my online assigment where they want me to create a button that displays a text in console.log when I click on it. Been at it for 3 hours now checking different forums, youtube videos and topics but can't find a specific "simple" answer. Can anyone help me out?

CodePudding user response:

function log() {
  console.log('Clicked');
};
<button onclick="log()">Click me!</button>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related