How do you get the value of an input, checkbox and radio button in jQuery?
<input type="text" id="name" value="Anita">
<input type="checkbox" id="agree" checked>
<input type="radio" name="plan" value="free">
<input type="radio" name="plan" value="pro" checked>
console.log($('#name').val());
console.log($('#agree').is(':checked'));
console.log($('input[name=plan]:checked').val());
Console output
Anita
true
pro
See jQuery Forms.
Learn more about the similar topics:
| Tutorials |
|---|
| jQuery Forms |
| Interview Questions & Answers |
|---|
| How do you get the value of an input, checkbox and radio button in jQuery? |
| How do you serialize a form in jQuery? |