문제

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/

도움이 되었습니까?

해결책

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.

다른 팁

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('');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top