X'Byte X'Byte - 2 years ago 80
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 */
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download