Pergunta

This is very likely a bug, but I'm reporting it here for reference and for the slight chance of someone being able to propose a workaround.

IE 11 supports the placeholder attribute natively on textarea elements. That's great. But adding a new textarea with a placeholder to the DOM, it automatically puts the placeholder text into the textarea's field, too!

Here's the repro: http://jsfiddle.net/wE577/1/

Foi útil?

Solução

Fiddling around on jsfiddle, it turns out that from jQuery 1.9 onwards, this problem does not occur: http://jsfiddle.net/wE577/2/.

A weird problem indeed. Unfortunately, my google foo didn't turn up any bug reports on this.

Since at the moment, we cannot upgrade jQuery beyond 1.8.3 (although I hope we soon will), a workaround I came up with is setting the placeholder attribute after adding the new textarea element to the DOM, which works flawlessly.

Outras dicas

We are using jquery version 1.10.1 but still facing the issue,

<textarea placeholder='Max 250 characters'>Max 250 characters</textarea>

For this we emptied the value of textarea while clicking (or calling), like this

$('#textareaID textarea').val('');
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top