【发布时间】:2009-08-19 15:39:22
【问题描述】:
我有以下html:
<html>
<head></head>
<body>
<form>
<input id="msg" type="text" value="oldValue" />
</form>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script>
$().ready(function() {
var m = $("#msg");
alert(m.val()); // returns oldValue
m.val("newValue"); // this doesn't make the browser show newValue instead of oldValue
alert(m.val()); // returns newValue
// and in the end, the browser still shows oldValue for the input
});
</script>
</body>
</html>
这段代码运行完美,但是当放置在一个 facebox(它只是创建一个 iframe 并将其显示为一个浮动窗口)时,代码无法更新输入的内容。
父级也有 jQuery,但这不会影响我的猜测。
任何想法为什么它失败了?
【问题讨论】:
-
您是否尝试过获取实际的 DOMElement 而不是使用 jQuery 的方法来做到这一点?