javascript - jQuery - Set background color from multiple buttons' inner text -


i'm trying change background color multiple buttons based of inner text using jquery. easy enough straight javascript using loop can't figure out how same thing in jquery.

here's i'm at:

$('button').click(function(){     $(body).css('background-color', "$('button').text()"); }); 

you setting string, not value of text. , want use this reference element clicked. using $("button") return text of first button.

$('button').click(function(){     $(body).css('background-color', $(this).text()); }); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -