0
Cant interact with button (HTML & JS)
<button>Like</button> <script> $("button").on("click", function() { alert("Button Clicked!") }); </script> ---------- I am new to HTML / JS. Why can't I interact with this button with the code above?
3 odpowiedzi
+ 3
Yes, before using jQuery first I should import it. Then I am adding an "Id" to the button. Select the button with jQuery and then defined a function with event listener => "click".
+ 1
You can see here my solution. I hope it helps you.
https://code.sololearn.com/WUBggyqVOvXu/?ref=app
0
Thanks very much. I noticed you added a JQuery script, named the button and assigned the JS code to the btn variable, which is the name of the button. I think I understand what you did. Thanks again for the response.