我有以下 textarea html 来帮助解决使用 IE10 时使用占位符值的占位符文本值不消失的问题
<textarea id="answerText" name="answerText" placeholder="Your answer here..." onfocus="this.placeholder = \'\'" onblur="this.placeholder = \'Your answer here...\'">@answer.Text</textarea>
对于第一个答案,这是按预期呈现的,但是当尝试使用 javascript 为第二个答案附加 textarea 时,onfocus 和 onblur 事件似乎不起作用,因为当我单击 textarea 时,占位符值仍然存在。这是我的代码:
$('#answerList').append('<li><div class="row"><div class="eight columns"><textarea id="answerText" name="answerText" placeholder="Your answer here..." onfocus="this.placeholder = \'\'" onblur="this.placeholder = \'Your answer here...\'"></textarea></div><div class="four columns"><input type="checkbox" name="correctCheckbox" id="correctAnswerCheckbox' + answerPosition + '" value="' + answerPosition + '"/><label for="correctAnswerCheckbox' + answerPosition + '">Correct Answer</label></div></div></li>');