0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

コピペで音を鳴らす(JavaScript)

Last updated at Posted at 2021-07-22

# コード

javascript.js
    var music = new Audio();//Audioオブジェクトの取得
    music.preload = "auto";//ページ読み込み時に、オーディオ・ファイルを読みこまれる
    music.src = "音声ファイルがあるパスを選択";//srcは「source(ソース、資源)」の略でソースを指定できる
    music.load();
    //ユーザが何か動作しないと音がならない
    window.addEventListener('イベント', (e) =>{
      music.play();//音声を再生する 
    })

これで完成!!

0
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?