views:

72

answers:

1

I'm trying to learn codeigniter and jquery. There is always a val() that nobody explains. What is it for?

+7  A: 

When it comes to jQuery, it is all in the documentation.

Essentially, the val function is to set or get the value of an element.

If you have an input field, like so:

<input name='my_field' id='my_field' value='Hello World'>

Then you can do this to get the value of the field:

var value = $('#my_field').val();

Or do this to set the value of the field:

$('#my_field').val('My new value');
Paolo Bergantino
Where are the docs?
Delirium tremens
He linked to the specific page.
BipedalShark
see the link on the first line of the answer
Jimmy