Skip to content

Instantly share code, notes, and snippets.

@torazuka
Created November 27, 2010 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torazuka/718014 to your computer and use it in GitHub Desktop.
Save torazuka/718014 to your computer and use it in GitHub Desktop.
html値、text値の挿入とクリックイベント
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>html値、text値の挿入とクリックイベント</title>
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script>
$(document).ready(function() {
$("button#q1").click(function() {
$("p#e1").text("大丈夫だ。問題ない。");
$("div#q").html("\<button\ type\=\"button\"\ id\=\"q2\"\>そんな装備で大丈夫か??\<\/button\>");
$("button#q2").click(function() {
$("p#e2").text("一番いいのを頼む。");
});
});
});
</script>
</head>
<body>
<h1>html値、text値の挿入とクリックイベント</h1>
<h2>クリックイベントの生成</h2>
<button type="button" id="q1">そんな装備で大丈夫か?</button>
<p id="e1"></p>
<div id="q"></div>
<p id="e2"></p>
<h2>メモ</h2>
<p>ボタンを押すと、文字列とボタン、ボタンのクリックイベントを生成する。</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment