【发布时间】:2011-05-23 15:54:57
【问题描述】:
也许我在这里没有理解一些基本的东西,但是 html() 调用不会返回填充了所有属性的元素,即使在显式调用设置属性之后也是如此。
例如,我有一个文本框:
<input type="text" id="foo" value="" />
当用户在这个框中填写一个值时,会调用一个函数(输入文本框的onBlur)。
$('#foo').blur(function(event) { updateFoo(this); });
在该函数中存在以下代码:
function updateFoo(input) {
// force DOM update??
$('#'+input.id).attr('value', input.value);
// successfully displays value user entered
alert($('#'+input.id).attr('value'));
// displays input element, with value not filled in,
// like: 'input type="text" id="foo" value="" />'
alert($('#'+input.id).parent().html());
...
}
html()调用不应该返回设置了value属性的元素吗?
我在 Max OSX 上使用 Firefox 3.6.13。
我看到了这个论坛帖子:http://forums.asp.net/t/1578929.aspx 我的一些假设基于...
谢谢, 盖伦
【问题讨论】: