回答編集履歴

2

tuiki

2018/05/29 05:35

投稿

yambejp
yambejp

スコア114585

test CHANGED
@@ -23,3 +23,53 @@
23
23
  <label><input type="checkbox">新しいタブで開く</label><a href="hoge.php">hoge</a>
24
24
 
25
25
  ```
26
+
27
+
28
+
29
+ # sample
30
+
31
+ 認識の違いがあるようなので。
32
+
33
+ リンクを必ずしもアンカーで開く必要はない・・・という考え方もあります
34
+
35
+ おすすめはしませんけど
36
+
37
+ ```javascript
38
+
39
+ $(function(){
40
+
41
+ $(':checkbox').on('change',function(){
42
+
43
+ $(this).closest('label').next('span').data('target',$(this).prop('checked')?'_blank':'_self');
44
+
45
+ }).trigger('change');
46
+
47
+ $('span[data-href]').css({
48
+
49
+ "text-decoration":"underline"
50
+
51
+ }).hover(function(){
52
+
53
+ $(this).css({"color":"red","cursor":"pointer"})
54
+
55
+ },function(){
56
+
57
+ $(this).css({"color":""})
58
+
59
+ }).on('click',function(){
60
+
61
+ window.open($(this).data('href'),$(this).data('target'));
62
+
63
+ }).trigger('change');
64
+
65
+ });
66
+
67
+ ```
68
+
69
+ ```HTML
70
+
71
+ <label><input type="checkbox">新しいタブで開く</label><span data-href="hoge.php">hoge</span>
72
+
73
+
74
+
75
+ ```

1

修正

2018/05/29 05:35

投稿

yambejp
yambejp

スコア114585

test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  最初から選択肢を提示しておくことです
4
4
 
5
- さらに気になる右クリックを無効化してください
5
+ さらに気になるなら右クリックを無効化してください
6
6
 
7
7
  ```javascript
8
8