回答編集履歴
1
sample
answer
CHANGED
@@ -1,3 +1,20 @@
|
|
1
1
|
idやclassをつけた上で、cssで指定してはいけないのでしょうか?
|
2
|
-
buttonに直接hoverを指定するのであれば、onmouseoverとonmouseoutを
|
2
|
+
buttonに直接hoverを指定するのであれば、onmouseoverとonmouseoutを
|
3
|
-
それはそれで面倒です
|
3
|
+
指定するのでしょうけどそれはそれで面倒です
|
4
|
+
|
5
|
+
# 追記
|
6
|
+
一応onmouseover/outの例だけ上げておきます
|
7
|
+
|
8
|
+
```javascript
|
9
|
+
<form></form>
|
10
|
+
<script>
|
11
|
+
var form = document.getElementsByTagName('form');
|
12
|
+
var btn = document.createElement('button');
|
13
|
+
btn.style = 'width: 50px';
|
14
|
+
btn.textContent = 'button';
|
15
|
+
btn.addEventListener ('mouseover',function(){this.style.boxShadow="0 7px 0 #f7ba59";});
|
16
|
+
btn.addEventListener ('mouseout',function(){this.style.boxShadow="";});
|
17
|
+
form[0].appendChild(btn);
|
18
|
+
</script>
|
19
|
+
|
20
|
+
```
|