var btnReady = document.getElementById ('ready');

 btnReady.addEventListener ('click', function () {
   pasteText (h2, sayPhrase [0]);
   changeCss (h2, 'color', '# 000');
   changeCss (lampImg1, 'display', 'none');
   changeCss (btnRepeat, 'cursor', 'default');
   changeCss (lampImg2, 'display', 'block');
   changeCss (dontClick, 'display', 'none');
   changeCss (btnReady, 'display', 'none');
   changeCss (btnRepeat, 'display', 'block');
   play ('audio / LightSwitch.mp3');
   changeCss (rightBlock, 'backgroundColor', "# 000");
   changeCss (leftBlock, 'backgroundColor', "# fff");
   changeCss (rightBlock, 'backgroundImage', "url (img / troll.png)");
   setAnimate (lampImg2, 'animated swing');
 }, false);

 function changeCss (node, selector, property) {
   node.style [selector] = property;
 }
  • Why not? changeCss your function? - Yuri
  • Yes, yes, this is a function - Denisoed
  • Just looks too massive)) - Denisoed
  • Have you written this function or pasted from somewhere? - Yuri
  • I wrote this feature - Denisoed

1 answer 1

Everything is fine with you, but I would changeCss function into this:

 var btnReady = document.getElementById('ready'); btnReady.addEventListener('click', function(){ changeCss(btnReady, {'background-color': 'red', 'color': 'white', 'border': '0'}) }, false); function changeCss(obj, styles) { for(key in styles){ obj.style[key] = styles[key]; }; }; 
 <button id="ready">Клик</button> 

  • Comments are not intended for extended discussion; conversation moved to chat . - PashaPash