当前位置:网站首页>js实现双向数据绑定
js实现双向数据绑定
2022-06-27 05:41:00 【小-黯】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" value="1" id="input">
<script>
var obj ={
}
var input = document.getElementById('input');
Object.defineProperty(obj, "txt", {
get: function(){
console.log("读取数据");
return input.value;
},
set: function(val){
console.log("修改数据", val);
input.value = val;
}
})
input.addEventListener("keyup", function(e){
obj.txt = input.value;
})
</script>
</body>
</html>
边栏推荐
- QListWidget中的内容不显示
- [cocos creator 3.5.1] addition of coordinates
- QT using Valgrind to analyze memory leaks
- Unicast, multicast and broadcast of IP network communication
- C语言实现定时器
- 树莓派4B上运行opcua协议DEMO接入kubeedge
- 资深【软件测试工程师】学习线路和必备知识点
- 面试:Selenium 中有哪几种定位方式?你最常用的是哪一种?
- 使用域名转发mqtt协议,避坑指南
- Leetcode298 weekly race record
猜你喜欢

LeetCode-515. 在每个树行中找最大值
![Mechanical transcoding journal [17] template, STL introduction](/img/78/926db660139fda3d31cceccad7096c.png)
Mechanical transcoding journal [17] template, STL introduction

双位置继电器XJLS-8G/220

Qt使用Valgrind分析内存泄漏

How win 10 opens the environment variables window

Reading graph augmentations to learn graph representations (lg2ar)

Web3还没实现,Web5乍然惊现!

Some articles about component packaging and my experience

齐纳二极管 稳压二极管 SOD123封装 正负区分

LeetCode-515. Find the maximum value in each tree row
随机推荐
什么是BFC?有什么用?
Using domain name forwarding mqtt protocol, pit avoidance Guide
Zener diode zener diode sod123 package positive and negative distinction
OpenCV的轮廓检测和阈值处理综合运用
Comprehensive application of OpenCV in contour detection and threshold processing
Acwing's 57th weekly match -- BC question is very good
多线程基础部分Part2
多线程基础部分Part3
Neon optimization 1: how to optimize software performance and reduce power consumption?
多线程基础部分Part 1
leetcode298周赛记录
three.js第一人称 相机前枪的跟随
[FPGA] realize the data output of checkerboard horizontal and vertical gray scale diagram based on bt1120 timing design
Terminal in pychar cannot enter the venv environment
Edge在IE模式下加载网页 - Edge设置IE兼容性
STM32关闭PWM输出时,让IO输出固定高或低电平的方法。
齐纳二极管 稳压二极管 SOD123封装 正负区分
Two position relay rxmvb2 r251 204 110dc
leetcode299周赛记录
expect脚本中使用scp命令的方法,expect脚本中scp命令获取不了值的问题完美解决方法
