javascript - Change background color of a div temporarily on click and then set to a different color -


another noobie question. trying create smartphone app using html, css, js , phonegap build. when user taps button or image i'd change div background color white yellow, play short sound clip , set background color pale yellow.

i have dozens of these divs , have class assigned. have class .formal, others .informal , others .spanish. far can play sound only. i've tried adapting other solutions i've seen background color won't change. think need identify instance of class clicked, change bg color play sound , change bg color light yellow. have removed code clarity below.

thanks assistance can provide me.

here's html sample div

<div class="formal">   <a href="#" onclick="playaudio('/android_asset/www/test.mp3');">play ay caramba</a> </div> 

and here's "playaudio" js

function playaudio(src) {   // change bg color div yellow here   if (my_media == null) {     // create media object src     my_media = new media(src, onsuccess, onerror);   } // else play current audio   // play audio   my_media.play();   // change background color light yellow here   } 

if can use jquery that

you have that

     function playaudio(src) {  // change bg color div yellow here  $("formal").css('background-color','yellow');  if (my_media == null) {         // create media object src         my_media = new media(src, onsuccess, onerror);     } // else play current audio     // play audio     my_media.play();   // change background color light yellow here   $("formal").css('background-color','blue');       } 

you can put hex color color want


Comments