4

I need to test if the BootStrap radio button is checked. Here is my approach but it does not work. How could I verify if the radio button is Checked?

<script> function optChange() { if (document.getElementById("optEventType").val() == 'yes'){ /// Do something..... } } </script> <form> <div id ="optType" onchange="optChange()" class="radio"> <label><input type="radio" name="opt1" id = "opt1">Tex21 </label> <label><input type="radio" name="opt1" id = "opt2">Text2</label> </div> </form> 
0

1 Answer 1

7
if ($("#opt1").is(":checked"))) { // do A } else if ($("#opt2").is(":checked")) { // do B } 

You have a similar answer here: jQuery, checkboxes and .is(":checked")

But I saw that you used ids attributes in the options so I use it for your answer..

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.