Mendel Yaffe Mendel Yaffe - 7 months ago 10
Javascript Question

How can I get this code to change the background color every other click?

The div tag referred to is the only code that I added to the HTML text. If possible please provide your answer in just jquery.
$(document).ready(function(){
$("div").click(funcOne(), funcTwo());

$.funcOne = function(x) {document.getElementsByTagName("div").style.backgroundColor = "blue";};

$.funcTwo = function(x) { document.getElementsByTagName("div").style.backgroundColor = "red";};
});

Answer
$('div').click(function(){ 
    this.style.backgroundColor = this.style.backgroundColor === 'blue' ? 'red' : 'blue' 
})