Using jQuery I want to check if checkboxes or radio button inside a div tag is selected and get the value of selected checkbox and radio buttons.
For Example:
<div>
Question
<div>
What is your name?
</div>
<div>
<input type="radio" name="r1" checked/>abc<br/>
<input type="radio" name="r1"/>pqr<br/>
<input type="radio" name="r1"/>lmn<br/>
</div>
</div>
<div style="visibility: hidden">
Question
<div>
What is your company name?
</div>
<div>
<input type="checkbox" name="c1" checked/>comp1<br/>
<input type="checkbox" name="c1"/>Comp2<br/>
<input type="checkbox" name="c1"/>Comp3<br/>
</div>
</div>
on button click I want to show question and in front of that the answer of that question. Like as follows
What is your name = abc
What is your company name = comp1, comp2
Thanks.
See http://api.jquery.com/checked-selector/ on how to use the :checked selector.