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

I've been coding for a week and I'm stuck on my online assigment where they want me to create

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?

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?

Share Improve this question asked Dec 5, 2021 at 19:53 DanyealDanyeal 511 gold badge1 silver badge6 bronze badges 6
  • 1 Wele, to improve your experience on SO please read about How to ask a good question in the help center. The idea is for you to try to get something to work and then e here with specific problems you are unable to resolve. Your question lacks any attempt at solving this problem on your own. Also consider obligations before asking. – Randy Casburn Commented Dec 5, 2021 at 19:54
  • 2 Think this through> There are 3 things you need - an html button, a javascript console.log statement and an event listener that will connect the 2 together. Google those concepts – Kinglish Commented Dec 5, 2021 at 19:56
  • 2 Always rely on the very good MDN Documentation for all things HTML, CSS and JavaScript. For example, here are some examples – Randy Casburn Commented Dec 5, 2021 at 19:56
  • @Kinglish - I will check event listener out - first time im hearing about it but we havent gone through it on the course yet. Thank you! – Danyeal Commented Dec 5, 2021 at 20:08
  • @RandyCasburn Thank you for that document - will take a look at it! Btw, is this the right way to reply to people? with a @? – Danyeal Commented Dec 5, 2021 at 20:17
 |  Show 1 more ment

1 Answer 1

Reset to default 4

function log() {
  console.log('Clicked');
};
<button onclick="log()">Click me!</button>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744213206a4563432.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信