回答編集履歴
2
test
test
CHANGED
@@ -47,3 +47,61 @@
|
|
47
47
|
```
|
48
48
|
|
49
49
|
# textarea対応
|
50
|
+
|
51
|
+
```javascript
|
52
|
+
|
53
|
+
<script>
|
54
|
+
|
55
|
+
document.addEventListener('input',e=>{
|
56
|
+
|
57
|
+
const t=e.target;
|
58
|
+
|
59
|
+
if(t.closest('[type=text]')){
|
60
|
+
|
61
|
+
t.addEventListener('input',()=>{
|
62
|
+
|
63
|
+
if(t.value){
|
64
|
+
|
65
|
+
t.setAttribute('value',t.value);
|
66
|
+
|
67
|
+
}else{
|
68
|
+
|
69
|
+
t.removeAttribute('value');
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
});
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
if(t.closest('textarea')){
|
78
|
+
|
79
|
+
t.addEventListener('input',()=>{
|
80
|
+
|
81
|
+
t.textContent=t.value??'';
|
82
|
+
|
83
|
+
});
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
function reqestHardcopy() {
|
90
|
+
|
91
|
+
var printData = document.getElementsByTagName('html')[0].innerHTML;
|
92
|
+
|
93
|
+
console.log(printData);
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
</script>
|
98
|
+
|
99
|
+
<input type="button" onclick=reqestHardcopy() value="button">
|
100
|
+
|
101
|
+
<p>Input Data</p>
|
102
|
+
|
103
|
+
<input type="text">
|
104
|
+
|
105
|
+
<textarea></textarea>
|
106
|
+
|
107
|
+
```
|
1
textarea
test
CHANGED
@@ -45,3 +45,5 @@
|
|
45
45
|
<input type="text">
|
46
46
|
|
47
47
|
```
|
48
|
+
|
49
|
+
# textarea対応
|