문제

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!

도움이 되었습니까?

해결책

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

$("input:text").click(function() {
  $(this).val(""); 
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top