我想从使用jquery进行引导的单选按钮中获取价值
我尝试了这个但没用
$('#search-type input').on('change', function() {
alert($('input[name=\'options\']:checked', '#search-type').val());
});
<div class="btn-group btn-group-toggle" data-toggle="buttons" id="search-type">
<label for="Search">Search for: </label>
<label class="btn btn-secondary active">
<input type="radio" name="options" id="option1" autocomplete="off" value="Photo" checked> Photo
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option2" autocomplete="off" value="Video"> Video
</label>
</div>
答案 0 :(得分:0)
尝试一下
<script type="text/javascript">
$(document).ready(function(){
$("input[type='button']").click(function(){
var radioValue = $("input[name='options']:checked").val();
if(radioValue){
alert("Your are a - " + radioValue);
}
});
});
</script>
希望有帮助。