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

回答編集履歴

3

訂正

2020/09/04 11:00

投稿

AkitoshiManabe
AkitoshiManabe

スコア5434

answer CHANGED
File without changes

2

訂正

2020/09/04 11:00

投稿

AkitoshiManabe
AkitoshiManabe

スコア5434

answer CHANGED
@@ -15,14 +15,15 @@
15
15
  ? "https://example.com/b.css"
16
16
  : "https://example.com/a.css" // typo 修正
17
17
  ;
18
+
19
+ // 実行中のscript の前に link[rel="stylesheet"] を置く
18
- document.head.appendChild(
20
+ document.head.insertBefore(
19
21
  Object.assign(document.createElement("link"),
20
22
  {
21
23
  rel:"stylesheet",
22
24
  type:"text/css",
23
25
  href
24
- })
26
+ }), document.currentScript );
25
- );
26
27
  ```
27
28
 
28
29
  jQuery の``$(function (){ /* js-code */ })()`` は ``DOMContentLoaded`` 発生まで実行されません。

1

typo の修正

2020/09/04 11:00

投稿

AkitoshiManabe
AkitoshiManabe

スコア5434

answer CHANGED
@@ -13,7 +13,7 @@
13
13
  let
14
14
  href = location.hash == "#example"
15
15
  ? "https://example.com/b.css"
16
- : "https://example.com/b.css"
16
+ : "https://example.com/a.css" // typo 修正
17
17
  ;
18
18
  document.head.appendChild(
19
19
  Object.assign(document.createElement("link"),