Reputation: 4749
I'm trying to learn codeigniter and jquery. There is always a val() that nobody explains. What is it for?
Upvotes: 0
Views: 415
Reputation: 488714
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');
Upvotes: 8