I'm playing with twitter bootstrap 3 and its new radio buttons and cannot seem to get which button is checked.
My buttons are like this:
<div class="form-group">
<label for="inputLogType" class="col-lg-2 control-label">Log type</label>
<div class="col-lg-10">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="inputLogType" id="splunk">Splunk
</label>
<label class="btn btn-primary">
<input type="radio" name="inputLogType" id="pig">PIG
</label>
</div>
</div>
</div>
I can get whether either button is clicked through $(".btn-group").click()
, but inside there I can't get which button is clicked. I'll get the 2 buttons through jquery $("input[name='inputLogType']")
, and one of them will have checked:true
property. However when I do $("input[name='inputLogType']:checked")
, nothing shows up.
Anyone knows what's wrong?
Are you trying to access the :checked
value in the click callback? If so, it's likely that the property hasn't been applied yet.
You can use $(event.target).find('input');
to select the targeted radio button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With