LoginSignup
0
0

More than 1 year has passed since last update.

JavaScript  メソッド「getElementById」「innerHTML」 

Posted at
/*内容一文省略*/
<body>

<h1>test</h1>
<p id="myPar">This is paragraph</p>
<div id="myDiv">This is Div</div>
<p>
<button type="button" onclick="myFunction()">Click</button>
</p>
<script>
function myFunction(){
    // 引き換え内容1
  var content1 = "「getElementById」テスト";
  // 引き換え内容1
  var content2 = "「innerHTML」テスト";
  //「getElementById」「innerHTML」テスト
	document.getElementById("myPar").innerHTML = content1;
	document.getElementById("myDiv").innerHTML = content2;
}
</script>
<p>when you click button up,the content will change</p>

</body>
</html>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0