views:

5

answers:

1

Hey.

I've a few inputs and I want to clear their values after clicking. How to?

 <input type="text" value="Name" />

I've tried:

$(this).inputValue(""); 

But it doesn't work. If I'm unable to change the value, how to add text to the input ($(this).text(""); works very well in, for example, textareas).

Thanks!

A: 

Use .val(newValue) for setting the value of any input type element (including <textarea> and <select>), like this:

$("input:text").click(function() {
  $(this).val(""); 
});
Nick Craver
Where can I find all the names of nod elements for JS/jQuery? I mean I was trying with value/inputvalue, but it's val. is there a list of shortcuts?
fomicz
@fomicz - The official API site here: http://api.jquery.com/ easy to search for what you're after :)
Nick Craver