I have the following HTML and would like to use Bootstrap's button plugin - .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?
I have the following HTML and would like to use Bootstrap's button plugin - http://twitter.github./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?
Share Improve this question edited Apr 19, 2013 at 23:28 Baylor Rae' 4,01022 silver badges40 bronze badges asked Jun 13, 2012 at 19:11 BenBen 6,08611 gold badges52 silver badges73 bronze badges1 Answer
Reset to default 10You'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);
});