'use strict';
const btn = document.getElementById('btn');
const kiroku = document.getElementById('kiroku');
let count = 0;
let list;
const click = btn.addEventListener('click',function omikuji(){
count++;
const number = Math.random();
if(number < 0.3 ){
btn.textContent='唐揚げ';
btn.style.color = 'yellow';
alert('ぴよ!');
}else if(number < 0.7){
btn.textContent = 'チキン南蛮';
btn.style.color = 'blue';
}else{
btn.textContent = '西京焼き';
btn.style.color = 'green'
}
if(count > 0){
list = document.createElement('li');
list.setAttribute('id',count);
list.textContent =`${count}回目は${btn.textContent}`;
kiroku.appendChild(list);
}
});
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme