回答編集履歴
2
訂正
test
CHANGED
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
$selectedKoma = $(this);
|
60
60
|
|
61
|
-
if ($selectedKoma.hasClass('droppable')) console.log("テスト");
|
61
|
+
if (!$selectedKoma.hasClass('droppable')) console.log("テスト");
|
62
62
|
|
63
63
|
$selectedKoma.css('background-color', 'yellow').addClass("droppable");
|
64
64
|
|
1
訂正
test
CHANGED
@@ -27,3 +27,43 @@
|
|
27
27
|
```
|
28
28
|
|
29
29
|
イベントのバブリングは`.koma`の方が`document`よりも早いため、未選択のコマをクリックした時は`droppable`クラスがついているはずです。それを利用しています。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
##### 訂正
|
34
|
+
|
35
|
+
と思ったのですが、これだとダメですね……
|
36
|
+
|
37
|
+
こうですね。
|
38
|
+
|
39
|
+
```javascript
|
40
|
+
|
41
|
+
$('.koma').on('click', function(e){
|
42
|
+
|
43
|
+
$selectedKoma = $(this);
|
44
|
+
|
45
|
+
$selectedKoma.css('background-color', 'yellow').addClass("droppable");
|
46
|
+
|
47
|
+
console.log("選択されました。");
|
48
|
+
|
49
|
+
});
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
↓
|
54
|
+
|
55
|
+
```javascript
|
56
|
+
|
57
|
+
$('.koma').on('click', function(e){
|
58
|
+
|
59
|
+
$selectedKoma = $(this);
|
60
|
+
|
61
|
+
if ($selectedKoma.hasClass('droppable')) console.log("テスト");
|
62
|
+
|
63
|
+
$selectedKoma.css('background-color', 'yellow').addClass("droppable");
|
64
|
+
|
65
|
+
console.log("選択されました。");
|
66
|
+
|
67
|
+
});
|
68
|
+
|
69
|
+
```
|