Skip to content

Instantly share code, notes, and snippets.

Last active November 1, 2019 08:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<!DOCTYPE html>
<meta charset="utf-8">
<title>演習5-1 配列操作とHTMLの一括操作</title>
<script src="ex05-1.js"></script>
<input type="button" value="数える" onclick="countElements();">
<input type="button" value="倍" onclick="doubleElements();">
<ol id="list">
function countElements() {
var elements = document.getElementsByTagName("li");
function doubleElements() {
var elements = document.getElementsByTagName("li");
var length = elements.length;
var list = document.getElementById("list");
var element = "<li>liタグだよ</li>";
list.innerHTML = "";
for(var i = 0; i < length * 2; i++) {
list.innerHTML += element;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment