HTML Forms contains various elements like input fields, options,
textarea ,option etc. No doubt for further processing, there is a need to get
value of each field.
we have taken four form elements in our example – input field, radio button and a textarea,option.
- To get value of input field.
- To get value of Checked Radio Button.
$( "form input[type='radio']:checked" ).val();
|
- Get value of Radio button with onChange.
$( 'input:radio' ).change( function (){
var value = $( "form input[type='radio']:checked" ).val();
alert( "Value of Changed Radio is : " +value);
});
|
- To get value of Textarea field.
- To Read Select Option Value
$('#selectId').val();
- To Set Select Option Value
$('#selectId').val('newValue');
$('#selectId>option:selected').text();
No comments:
Post a Comment