IE11 + jQuery 1.8.3:动态添加带有占位符的textarea并将文本设置为占位符 [英] IE11 + jQuery 1.8.3: dynamically added textarea with placeholder has text set to placeholder

查看:189
本文介绍了IE11 + jQuery 1.8.3:动态添加带有占位符的textarea并将文本设置为占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很可能是一个错误,但是我在这里报告该错误以供参考,也可能是某人有可能提出解决方法的机会.

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本身在textarea元素上支持placeholder属性.那太棒了.但是,向DOM添加带有占位符的新textarea时,它也会自动将占位符文本放入textarea的字段中!

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!

这是复制品: http://jsfiddle.net/wE577/1/

推荐答案

摆在jsfiddle上,事实证明,从jQuery 1.9起,不会发生此问题:

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

确实是一个奇怪的问题.不幸的是,我的谷歌foo没有对此提出任何错误报告.

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

此刻,我们无法将jQuery升级到1.8.3以上(尽管我希望不久以后),我想到的解决方法是设置placeholder属性之后,并添加新的元素,可以完美地工作.

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.

这篇关于IE11 + jQuery 1.8.3:动态添加带有占位符的textarea并将文本设置为占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆