回答編集履歴

4

ついき

2019/10/03 05:08

投稿

kyoya0819
kyoya0819

スコア10429

test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  var lang = {en:'https://example.com/en/',ja:'https://example.com/ja/'};
18
18
 
19
- location.href(lang[className]);
19
+ window.location.href = lang[className];
20
20
 
21
21
  });
22
22
 
@@ -54,7 +54,7 @@
54
54
 
55
55
  var lang = {en:'https://example.com/en/',ja:'https://example.com/ja/'};
56
56
 
57
- location.href(lang[idName]);
57
+ window.location.href = lang[idName];
58
58
 
59
59
  });
60
60
 

3

tuiki

2019/10/03 05:08

投稿

kyoya0819
kyoya0819

スコア10429

test CHANGED
@@ -9,6 +9,8 @@
9
9
  ```jQuery
10
10
 
11
11
  $('a').click(function() {
12
+
13
+ event.preventDefault();
12
14
 
13
15
  var className = $(this).attr('class');
14
16
 
@@ -46,6 +48,8 @@
46
48
 
47
49
  $('a').click(function() {
48
50
 
51
+ event.preventDefault();
52
+
49
53
  var idName = $(this).attr('id');
50
54
 
51
55
  var lang = {en:'https://example.com/en/',ja:'https://example.com/ja/'};

2

追記

2019/10/03 05:07

投稿

kyoya0819
kyoya0819

スコア10429

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  ```
22
22
 
23
- [サンプル](https://codepen.io/asuchi0819/pen/dyybyYv?editors=1010#0)
23
+ [サンプル](https://codepen.io/asuchi0819/debug/dyybyYv/auth)
24
24
 
25
25
 
26
26
 

1

追記

2019/10/03 05:05

投稿

kyoya0819
kyoya0819

スコア10429

test CHANGED
@@ -19,3 +19,39 @@
19
19
  });
20
20
 
21
21
  ```
22
+
23
+ [サンプル](https://codepen.io/asuchi0819/pen/dyybyYv?editors=1010#0)
24
+
25
+
26
+
27
+
28
+
29
+ ---
30
+
31
+
32
+
33
+ IDだったら
34
+
35
+
36
+
37
+ ```HTML
38
+
39
+ <a id=en href=https://example.com>sample (EN)</a><br>
40
+
41
+ <a id=en href=https://example.com>sample (JA)</a>
42
+
43
+ ```
44
+
45
+ ```jQuery
46
+
47
+ $('a').click(function() {
48
+
49
+ var idName = $(this).attr('id');
50
+
51
+ var lang = {en:'https://example.com/en/',ja:'https://example.com/ja/'};
52
+
53
+ location.href(lang[idName]);
54
+
55
+ });
56
+
57
+ ```