【发布时间】:2009-11-14 02:47:48
【问题描述】:
我正在尝试使用 jquery 更新 textarea 的值,如下面的代码所示:
<button type="button" onclick="setLine();">Set</button>
<button type="button" onclick="showLine();">fire!</button><p></p>
<textarea id="hello">
</textarea>
<script type="text/javascript">
$('#hello').val("hi there");
</script>
<script type="text/javascript">
function showLine()
{
alert($('#hello').val());
}
function setLine()
{
$('#hello').val('foo');
}
</script>
此代码在除 IE6 之外的所有主流浏览器中都能正常运行。
在 Ie6 中,文本区域不会随着按钮单击而更新,并且警报会给出空白/空字符串。但是在其他浏览器中,单击“set”会将其更改为“foo”,然后会显示在警告框中。
有谁知道为什么这是特定于该浏览器的,或者代码可能有什么问题?我怀疑.val()
任何帮助将不胜感激。
【问题讨论】:
-
这是您在 jsbin 上的示例:jsbin.com/ivaso 我没有方便的 IE6 来测试它。
-
在 IE6 中尝试过,“按原样”完美运行
-
你用的是什么版本的jQuery?
标签: jquery internet-explorer-6