Skip to content

Instantly share code, notes, and snippets.

@xhackjp1
Last active February 19, 2019 07:39
Show Gist options
  • Save xhackjp1/70195733f96d74be524ce69ee082d7a3 to your computer and use it in GitHub Desktop.
Save xhackjp1/70195733f96d74be524ce69ee082d7a3 to your computer and use it in GitHub Desktop.
クリックイベント
<!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