質問するログイン新規登録

質問編集履歴

2

コードの修正2

2021/03/17 01:50

投稿

rei78087487
rei78087487

スコア12

title CHANGED
File without changes
body CHANGED
@@ -41,10 +41,9 @@
41
41
  そうなるとAddEventListenerになると思いますが…
42
42
  どなたかご教示お願いします。
43
43
 
44
-
44
+ ```JavaScript
45
45
  ***************************************イベント処理********************************
46
46
 
47
- ```JavaScript
48
47
  // 要素の作成
49
48
  const doubleClick = (e) => {
50
49
  obj.elm = document.createElement('textarea');

1

codeの修正

2021/03/17 01:50

投稿

rei78087487
rei78087487

スコア12

title CHANGED
File without changes
body CHANGED
@@ -44,70 +44,70 @@
44
44
 
45
45
  ***************************************イベント処理********************************
46
46
 
47
+ ```JavaScript
47
- ```// 要素の作成
48
+ // 要素の作成
48
49
  const doubleClick = (e) => {
49
50
  obj.elm = document.createElement('textarea');
50
51
  obj.elm.classList.add('child');
52
+ const combine = obj.elm;
51
53
 
52
- const combine = obj.elm;
53
- combine.onchange = () => {
54
+ combine.onchange = () => {
54
- if(combine.value !== "") {
55
+ if(combine.value !== "") {
55
- combine.style.backgroundColor = 'transparent';
56
+ combine.style.backgroundColor = 'transparent';
56
- combine.style.border = 'none';
57
+ combine.style.border = 'none';
57
- combine.style.resize = 'none';
58
+ combine.style.resize = 'none';
58
- } else {
59
+ } else {
59
- combine.style.backgroundColor = 'white';
60
+ combine.style.backgroundColor = 'white';
60
- combine.style.border = 'solid';
61
+ combine.style.border = 'solid';
61
- combine.style.borderWidth = 'thin';
62
+ combine.style.borderWidth = 'thin';
62
- }
63
+ }
63
- }
64
+ }
64
65
  elment.appendChild(obj.elm);
65
66
  obj.setPos(e);
66
67
  obj.elm = null;
67
68
  };
68
69
 
69
70
 
71
+
70
72
  // 右クリックメニュー
71
73
  const contextMenu = (e) => {
72
- const rightClick = document.querySelector('.menu');
74
+ const rightClick = document.querySelector('.menu');
73
- let t = e.target;
75
+ let t = e.target;
74
- if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
76
+ if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
75
- rightClick.style.display = "block";
77
+ rightClick.style.display = "block";
76
78
 
77
- if(t.getBoundingClientRect().top > 216) {
79
+ if(t.getBoundingClientRect().top > 216) {
78
- rightClick.style.left = t.getBoundingClientRect().left + 'px';
80
+ rightClick.style.left = t.getBoundingClientRect().left + 'px';
79
- rightClick.style.top =t.getBoundingClientRect().top - 216 + 'px';
81
+ rightClick.style.top =t.getBoundingClientRect().top - 216 + 'px';
80
- } else {
82
+ } else {
81
- rightClick.style.left = t.getBoundingClientRect().left + 'px';
83
+ rightClick.style.left = t.getBoundingClientRect().left + 'px';
82
- rightClick.style.top =t.getBoundingClientRect().top + 30 + 'px';
84
+ rightClick.style.top =t.getBoundingClientRect().top + 30 + 'px';
83
- }
85
+ }
84
86
  };
85
87
 
88
+
86
89
  // 文字の大きさメニュー 右クリック➡文字の大きさ➡文字の大きさメニュー表示
87
-
88
90
  const mouseMove2 = () => {
89
91
  fontMenu.style.display = "block";
90
92
  };
91
93
 
92
94
 
95
+
93
96
  // 文字の大きさメニュー 矢印↑クリック
94
-
95
97
  const contextMenu2 = (e) => {
96
-
97
-
98
98
  let t = event.target;
99
99
  const test = t;
100
100
  if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
101
101
 
102
- fontUp.addEventListener('click', (e) => {
102
+ fontUp.addEventListener('click', (e) => {
103
- if(inputFont.value >= 64) {
103
+ if(inputFont.value >= 64) {
104
- alert('64以上の数値は入力できません')
104
+ alert('64以上の数値は入力できません')
105
- return;
105
+ return;
106
- }
106
+ }
107
- inputFont.value = Number(inputFont.value) + 1;
107
+ inputFont.value = Number(inputFont.value) + 1;
108
- t.style.fontSize = Number(inputFont.value) + 'px';
108
+ t.style.fontSize = Number(inputFont.value) + 'px';
109
- });
109
+ });
110
- }
110
+ }
111
111
 
112
112
 
113
113
  // 文字の大きさメニュー矢印↓クリック
@@ -117,44 +117,47 @@
117
117
  if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
118
118
 
119
119
    fontDown.addEventListener('click', (e) => {
120
- if(inputFont.value >= 64) {
120
+ if(inputFont.value >= 64) {
121
- alert('64以上の数値は入力できません')
121
+ alert('64以上の数値は入力できません')
122
- return;
122
+ return;
123
- }
123
+ }
124
- inputFont.value = Number(inputFont.value) - 1;
124
+ inputFont.value = Number(inputFont.value) - 1;
125
- t.style.fontSize = Number(inputFont.value) + 'px';
125
+ t.style.fontSize = Number(inputFont.value) + 'px';
126
- });
126
+ });
127
- }
127
+ }
128
128
 
129
129
 
130
+
130
131
  //addEventListner→onclickに変更した場合
131
-
132
132
  // 文字の大きさメニュー 矢印↑クリック
133
133
  element.oncontextmenu = (e) => {
134
- let t = event.target;
134
+ let t = event.target;
135
- if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
135
+ if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
136
136
 
137
137
    fontUp.onclick = (e) => {
138
- if(inputFont.value >= 64) {
138
+ if(inputFont.value >= 64) {
139
- alert('64以上の数値は入力できません')
139
+ alert('64以上の数値は入力できません')
140
- return;
140
+ return;
141
- }
141
+ }
142
- inputFont.value = Number(inputFont.value) + 1;
142
+ inputFont.value = Number(inputFont.value) + 1;
143
- t.style.fontSize = Number(inputFont.value) + 'px';
143
+ t.style.fontSize = Number(inputFont.value) + 'px';
144
- }
144
+ }
145
- }
145
+ }
146
146
 
147
+
147
148
  // 文字の大きさメニュー矢印↓クリック
148
- element.oncontextmenu = (e) => {
149
+ element.oncontextmenu = (e) => {
149
150
  let t = event.target;
150
151
  if(t.nodeName != 'TEXTAREA' || !t.classList.contains('child')) return;
151
152
 
152
153
    fontDown.onclick = (e) => {
153
- if(inputFont.value >= 64) {
154
+ if(inputFont.value >= 64) {
154
- alert('64以上の数値は入力できません')
155
+ alert('64以上の数値は入力できません')
155
- return;
156
+ return;
156
- }
157
+ }
157
- inputFont.value = Number(inputFont.value) - 1;
158
+ inputFont.value = Number(inputFont.value) - 1;
158
- t.style.fontSize = Number(inputFont.value) + 'px';
159
+ t.style.fontSize = Number(inputFont.value) + 'px';
159
- }
160
+ }
160
- }`
161
+ }
162
+
163
+ ```