<!DOCTYPE html
>
<html
>
<head
>
<meta charset
="utf-8">
<title
></title
>
</head
>
<body
>
<div
>
<input id
="input" type
="text" name
="" id
="" value
="" />
<span id
="bind"></span
>
</div
>
</body
>
<script type
="text/javascript">
var input
= document
.getElementById('input')
var bind
= document
.getElementById('bind')
</script
>
<script type
="text/javascript">
var model
= new Object();
var val
= '';
Object
.defineProperty(model
, 'value', {
get
: function() {
return val
;
},
set
: function(v
) {
input
.value
= v
;
bind
.innerHTML
= v
;
val
= v
;
}
})
input
.addEventListener('keyup', function(e
) {
model
.value
= e
.target
.value
;
})
console
.log(model
.value
)
</script
>
</html
>
转载请注明原文地址:https://ipadbbs.8miu.com/read-53142.html