Skip to content
Advertisement

JavaScript equivalent of :active in CSS

I have the script that plays audio, the problem with the below script is that it plays when mouse click is released.

JavaScript

I want the above script to play on mouse click (similar to active on CSS)

Any help would be appreciated. Thanks.

Advertisement

Answer

Listen for the mousedown event instead:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement