0

I am trying to figur out how to clear textarea text on focus only if it has a certain word, phrase or charcter. I have found many solutions to clear the default text in a text area but if i have the two textarea's that say for instance one says "pass" and one says "fail" I want to be able to click in pass and be able to write more text and when I click on fail it clears fail on focus and then I can type text.

Pass could be deleted obviously if a person hit delete or backspace, but would not automatically clear on focus. I just want to clear on focus with default text of "Fail"

<textarea rows="4" cols="50">Pass</textarea>

<textarea rows="4" cols="50">Fail</textarea>
4

1 回答 1

0

something like this should work:

$('textarea').click(function(){
  if($(this).text() == "Fail"){
    $(this).text(null);
  }
});
于 2013-07-12T21:07:53.457 回答