javascript - is it possible to play a sound file onclick depends on url? -


Is it possible to onclick a sound file depends on the url?

Example: url / sample / # 1

Click on sound 1

url / sample / # 3

onclick play sound 2

Why do not you use html5 data-assets, they make HTML very clean < / P>

  & lt; Ul id = "audiolist" & gt; & Lt; Li data-auditive = "url_of_audio_file_1" & gt; Voice 1 & lt; / Li & gt; & Lt; Li data-auditive = "url_of_audio_file_2" & gt; Sound 2 & lt; / Li & gt; & Lt; / Ul & gt;   

and JavaScript

  & lt; Script type = "text / javascript" & gt; $ (Function () {$ ("# audiologist lee"). ("Click", function () {$ ("# audio"). Attr ({"src": $ (this) .attr (" ATR ({"src": $ ("# audiologist lee"). Eq (0) .attr ("data-audial") ("data-audial") "octal": "autoplay": "autoplay"})} $ ("# Audio"). "}})}} & Lt; / script>   

But if you want to url, then you want an anchor tag instead of a list Modify the code

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -