Search This Blog

Wednesday 30 July 2014

jQuery: Get Value Of Input, Textarea and Radio Button,Select,Option






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.
$("input").val();
  • 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.
$("textarea").val();
  • To Read Select Option Value
$('#selectId').val();
  • To Set Select Option Value
$('#selectId').val('newValue');
  • To Read Selected Text
$('#selectId>option:selected').text();




No comments:

Post a Comment