[HTML] 纯文本查看 复制代码 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>TIAOTIAOtiaowa1</title>
<meta name="Generator" content="EditPlus" />
<meta name="Author" content="" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<style>
textarea {
border: #ff0000 1px solid;
overflow: visible;
color: black;
font-size: 20px;
background-image: url([url]https://img03.sogoucdn.com/app/a/201025/7e65fdb5fd3ca37f2d2fc9b9eb64915d[/url]);
width: 400px;
height: 400px;
opacity: 0.5;
}
</style>
</head>
<script>
let dataObj = {};
Object.defineProperty(dataObj, "test", {
get: function () {
return 10;
},
set: function (newValue) {
console.log(newValue);
document.getElementById("test1").value = newValue;
},
});
document.addEventListener("keyup", function (event) {
dataObj.test = event.target.value.toUpperCase();
});
let dataObj2 = {};
Object.defineProperty(dataObj2, "test1", {
get: function () {
return 10;
},
set: function (newValue) {
console.log(newValue);
document.getElementById("test").value = newValue;
},
});
document.addEventListener("keyup", function (event) {
dataObj2.test1 = event.target.value.toLowerCase();
});
</script>
<body>
<div>在这里输入小写,会自动转为大写:</div>
<br /><textarea id="test"></textarea><br /><br />
<div>在这里输入大写,会自动转为小写:</div>
<br /><textarea id="test1"></textarea><br />
</body>
</html>
出个双向数据绑定版本。 |