I have a lot of input text tags. When focusing on the nth input, the melody should play.

function soundClick() { var audio = new Audio(); // Π‘ΠΎΠ·Π΄Π°Ρ‘ΠΌ Π½ΠΎΠ²Ρ‹ΠΉ элСмСнт Audio audio.src = 'click.mp3'; // Π£ΠΊΠ°Π·Ρ‹Π²Π°Π΅ΠΌ ΠΏΡƒΡ‚ΡŒ ΠΊ Π·Π²ΡƒΠΊΡƒ "ΠΊΠ»ΠΈΠΊΠ°" audio.autoplay = true; // АвтоматичСски запускаСм } 

This solution did not work because it is tied to the audio tag.

    1 answer 1

     function soundClick() { new Audio('click.mp3').play(); }