htmlボタン要素にJavaScriptを書き込もうとしています。しかし、それはページリロードを引き起こします。しかし、私はボタンの種類で入力を使用するとうまく動作します。これの理由は何ですか?ここでボタン要素を使用できないのはなぜですか?aspファイルのhtmlボタン要素を使用するとJavaScriptがページリロードを引き起こします
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Default</title>
<script type="text/javascript">
function changeTheText() {
document.getElementById("paragraphText").innerHTML = "The text is changed!";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p id="paragraphText">This is awesome!</p>
<button onclick="changeTheText()">Change the text</button>
<input type="button" onclick="changeTheText()" value="Click" />
</div>
</form>
ありがとうございました。私はそれを理解しました。または、button = "button"のようにタグのボタンタイプを変更することができました。 – TaroYuki