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

How to make Mootools get('html') including values of inputfields

本文关键字:输入 包括 字段 Mootools 何使 html 获取      更新时间:2023-09-26

当我有HTML输入字段并通过直接输入更改它们时,它们实际上应该更改那里的值属性。但当我试图获得整个HTML记录时,它只显示旧的值属性。不知何故,这对我来说很清楚,当然HTML没有被覆盖,但我需要包含更改的输入值的HTML。我该如何接近它?

的例子:

$('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包含元素的实际值。修改输入元素的默认值change defaultValue property:

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

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