# jQuery val()

jQuery val() method can either be used to get current value of the first element in the set of matched elements or to set the value of every matched element.

jQuery val() sets or returns the value attribute of the selected elements.

Syntax:

When it is used to get value.

$(selector).val()  When it is used to set value. $(selector).val(value)


Value: Value is a compulsory parameter, used to specify the value of the attribute.

When it is used to set value by calling function.