I want get value from radio button that made by bootstrap with jquery

I try with this but not work

    $('#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:&nbsp;</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>

1 Answers

0
Sumithran On

Try this,

<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>

Hope helpful.