JQuery and Twitter Bootstrap "button" plugin - select value

I have the following HTML and would like to use Bootstrap's button plugin - http://twitter.github.com/bootstrap/javascript.html#buttons to select the "value" element:

<div class="btn-group pull-right nav-tabs" data-toggle="buttons-radio">
  <button class="btn" value="60">Hour</button>
  <button class="btn" value="1440">Day</button>
  <button class="btn" value="10080">Week</button>
  <button class="btn" value="43200">30 Day</button>
</div>

I have the following JavaScript that executes onClick successfully, but returns undefined.

$('.nav-tabs').button().click( function(e){     

  var selected = $(this).attr('value');

  console.log(selected);
});

Can anyone advise how I can get the "value" element from the html?

Answers


You're not selecting the button. It should look like this.

$('.nav-tabs').on('click', 'button', function(e){     

  var selected = $(this).attr('value');

  console.log(selected);
});

Need Your Help

how to upload data to apple developer device

ios iphone objective-c ipad

If I am using xcode's simulator I can upload data to the app folder (/APPID/Documents) easily.

IE7 crashes when hiding textarea or parent container

javascript html

I have a form that checks to see if another window is opened. If so, it copies the values of two input fields to existing readonly input fields and hides two editable textareas by setting the elem...