Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 674
Danyeal Avatar asked Aug 31 '25 16:08

Danyeal


1 Answers

function log() {
  console.log('Clicked');
};
<button onclick="log()">Click me!</button>
like image 175
Lundstromski Avatar answered Sep 02 '25 07:09

Lundstromski