0
How I can use html button with a javascript code ex: button click--> alert("...")
help
7 Answers
+ 3
Full code:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button onclick="alert('This works!')">Click here</button>
</body>
</html>
+ 1
HTML:
<button onclick="click()">
JS:
function click() {
alert("...")
}
+ 1
onclick event:
<button onclick="alert('...')">Click me</button>
+ 1
To be fair, I'm getting the same issue. Can someone better than me show what's up?
https://code.sololearn.com/WdBBSZY8C80r/?ref=app
Edit: it seems the choice of the function name 'click' stops it being executed (because it's a keyword?). Changing the function name gets it to work.
0
ok thanks
0
but I have use your code but their isn't reaction
0
J'ai fait ça :
html:
<button onclick="click ()">
js:
function click (){
alert ("...");
}
mais ça ne fonctionne pas