Last active
February 19, 2019 07:39
-
-
Save xhackjp1/70195733f96d74be524ce69ee082d7a3 to your computer and use it in GitHub Desktop.
クリックイベント
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<p>Hello World!</p> | |
<button type="button" name="button" onclick="sample()">Click Me!</button> | |
<script> | |
var n = 0; | |
function sample() { | |
var p = document.createElement('p'); | |
p.textContent = 'こんにちは!' + n++; | |
//document内のbody要素の中にpタグを挿入する | |
document.body.appendChild(p); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment