gpt4 book ai didi

javascript - 如何使 Mootools 获取 ('html' ),包括输入字段的值

转载 作者:行者123 更新时间:2023-11-28 20:30:00 25 4
gpt4 key购买 nike

当我有 HTML 输入字段并通过直接输入更改它们时,它们实际上应该更改那里的 value 属性。但是当我尝试获取整个 HTML 记录时,它只显示旧的值属性。不知怎的,这对我来说很清楚,因为 HTML 没有被覆盖,但我需要包含更改后的输入值的 HTML。我该如何处理它?<​​/p>

示例:

$('input').addEvent('blur', function(){
alert($('adiv').get('html'));
});

<div id="adiv">Enter something in input box and press tab<div>....<input id="input" type="text" value="1">the mootools will grep the old value of 1 again....</div></div>

http://jsfiddle.net/hJtzc/1/

始终提醒:

> Enter something in input box and press tab<div>....<input id="input"
> type="text" value="1">the mootools will grep the old value of 1
> again....</div>

但我需要得到的是:

> Enter something in input box and press tab<div>....<input id="input"
> type="text" value="[VALUE FROM USER]">the mootools will grep the old
> value of 1 again....</div>

最佳答案

HTML 中的

属性 value 设置元素的初始默认值,DOM 属性 value 包含元素的实际值。要更改输入元素的默认值,请更改 defaultValue 属性:

$('input').addEvent('blur', function(){
this.defaultValue = this.value;
alert($('adiv').get('html'));
});

这是正常行为,与 mootools 框架无关

关于javascript - 如何使 Mootools 获取 ('html' ),包括输入字段的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16607924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com