Back

.val( [value] )

Get or set a value on the current set

If value is provided, this will set the value for each element and return the current set for chaining

If no arguments are passed, this will return the value of the first element in the current set

Params

value{Any} [optional]A value to be set. Functions will be evaluted with (previousValue, index) and the return value will be set.

Returns

Value or DollarJS (chainable)

Examples

$('p').val()
$('p').val('foo')
$('p').val(function(previousValue, index){ return 'foo'; })