jQuery Intro

jQuery Intro Quiz

jQuery Intro Exercise

jQuery Basic

jQuery Basic Quiz

jQuery Basic Exercise

jQuery Advance

jQuery Advance Quiz

jQuery Advance Exercise

jQuery Selectors

jQuery Effects

jQuery Events

jQuery Methods and Properties

jQuery Traversing

jQuery CSS and HTML Methods

Val() method in Jquery

val() Method



The jQuery val() method is used to get or set the values of form fields, such as text boxes, dropdowns, and many other inputs. Getting and setting form field values is very useful in order to handle form events and validation.




  1. Its syntax for returning value attribute is:- $(selector).val()
  2. Its syntax for setting value attribute is:- $(selector).val(value)
  3. Its syntax for setting value by function is:- $(selector).val(function(index,currentvalue))


Further Explanation:-


Parameter Description
value Required. Specifies the value of the value attribute
function(index,currentvalue) Optional. Specifies a function that returns the value to the set.
  • index - Returns the index position of the element in the set
  • currentvalue - Returns the current value attribute of selected elements

Code Explanation

All Tutorials related to jQuery Basic

All Sections related to jQuery