LoginSignup
0
0

More than 3 years have passed since last update.

江頭ゲーム

Last updated at Posted at 2021-01-13

ランダム関数で江頭を出現するかしないかを選択

偶数だったら江頭出現でそこからいくつか用意した江頭の写真を選択して表示

奇数だったら何もない画面に戻る

function setEgasira() {
    const Body = document.getElementById("www");
    const img_Egasira = document.createElement('div');
    const checkEgasira = Math.floor(Math.random() * 4);
    if (checkEgasira % 2 ===0) {
        if (checkEgasira === 0) {
            img_Egasira.innerHTML = "<img src='./img/egasira-1.jpg' alt='img_Egasira' width='250px' height=150px' />";
        } else if (checkEgasira === 2) {
            img_Egasira.innerHTML = "<img src='./img/egasira-2.jpg' alt='img_Egasira' width='250px' height=150px' />";
        }
        Body.appendChild(img_Egasira);
    } else {
        www.innerHTML=""
    }
}
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