X'Byte X'Byte - 1 year ago 71
Javascript Question

Alert user with selection from bootstrap button

Following this JSFiddle, I'm trying to alert() the user of his selection after he selects a button from the 'likert scale'.


Trying something like:

$(".btn btn-default").click(function () {

however it does not seem to be working. What am I missing?

Answer Source

You need to add a period and remove the space

$(".btn.btn-default").click(function () {
  alert($(this).text()); /* this alerts the text content of the button */