Tim C
Tim C

Reputation: 5714

Javascript change multiple element style on click

Consider the following images, which lets a user guess who will win a certain sports match

enter image description here

enter image description here

Im trying to do the following:

My problem

team[x] now has the selected team however im now stuck...and cant figure out how to change the team names style...from here.

Things To Consider:

Upvotes: 2

Views: 1020

Answers (1)

Ajai
Ajai

Reputation: 901

So you should be doing this. Add the same class for all clickable teams, say class="team". In your css add this

.selected{
   background-color:#fff;
}

Now using Jquery like this,

$('.team').click(function(){
   $(this).toggleClass('selected');
})

Upvotes: 3

Related Questions