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
Post a Comment