当前位置:网站首页>JS to implement bidirectional data binding
JS to implement bidirectional data binding
2022-06-27 05:54:00 【Small dark】
<!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(" Reading data ");
return input.value;
},
set: function(val){
console.log(" Modifying data ", val);
input.value = val;
}
})
input.addEventListener("keyup", function(e){
obj.txt = input.value;
})
</script>
</body>
</html>
边栏推荐
- 双位置继电器XJLS-8G/220
- 693. 交替位二进制数
- 30个单片机常见问题及解决办法!
- [FPGA] realize the data output of checkerboard horizontal and vertical gray scale diagram based on bt1120 timing design
- [FPGA] UART serial port_ V1.1
- IP网络通信的单播、组播和广播
- Neo4j community conflicts with neo4j desktop
- Leetcode298 weekly race record
- Luogu p2939 [usaco09feb]revamping trails G
- 【FPGA】 基于FPGA分频,倍频设计实现
猜你喜欢

导航【机器学习】

Small program of C language practice (consolidate and deepen the understanding of knowledge points)

LeetCode-515. Find the maximum value in each tree row

IAR systems fully supports Centrino technology 9 series chips

Ad22 Gerber files Click to open the Gerber step interface. Official solutions to problems

Double position relay rxmd2-1mrk001984 dc220v

Qt使用Valgrind分析内存泄漏

Codeforces Round #802 (Div. 2)

【QT小作】使用结构体数据生成读写配置文件代码

LeetCode-515. 在每个树行中找最大值
随机推荐
Gao Xiang slam14 lecture - note 1
STM32 MCU pin_ How to configure the pin of single chip microcomputer as pull-up input
Execution rules of pytest framework
openstack实例重启状态就会变成错误处理方法,容器搭建的openstack重启计算节点compute服务方法,开机提示Give root password for maintenance处理方法
【Cocos Creator 3.5.1】input.on的使用
js实现双向数据绑定
Acwing's 57th weekly match -- BC question is very good
双位置继电器RXMVB2 R251 204 110DC
Logu p4683 [ioi2008] type printer problem solving
mysql 查询时将状态改为相对应的文字
When STM32 turns off PWM output, it is a method to fix IO output at high or low level.
Machunmei, the first edition of principles and applications of database... Compiled final review notes
LeetCode-515. Find the maximum value in each tree row
Junda technology - centralized monitoring scheme for multi brand precision air conditioners
Avoid asteroids
Go日志-Uber开源库zap使用
Web3 has not been implemented yet, web5 suddenly appears!
[nips 2017] pointnet++: deep feature learning of point set in metric space
Spark 之 WholeStageCodegen
代码即数据
