-
-
Save ponsuke0531/3785efb1de2a737df1217e68f88342da to your computer and use it in GitHub Desktop.
JavaScriptの実装に役立つリンク集 ref: https://qiita.com/ponsuke0531/items/bf4b67e3ba4ae0df1390
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery(jQuery CDN) | |
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> | |
// jQuery(Google Hosted Libraries) | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
// jQuery-UI(jQuery CDN) | |
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script> | |
// bootstrap(MaxCDN) | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
// bootstrap-select(CDNJS) | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 配列定義:new Array より [] のほうが望ましい。とSublimeLinterに言われた。 | |
var arr = []; | |
var arr = [1, 2, 3]; | |
// 要素数を数える:Javaと並走して実装していると()をつけたくなりますが不要です。 | |
var count = arr.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery : name属性指定 | |
let a = $('input:hidden[name="name属性"]').val(); | |
let b = $("input:hidden[name='name属性']").val(); | |
// jQuery : id属性指定 | |
let c = $("#id属性").val(); | |
let d = $('#id属性').val(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XMLHttpRequestはローカルのJSONファイルを読み込めません。Cross origin要求は、http、data、chrome、chrome-extension、https、chrome-extension-resourceのプロトコルスキームでのみサポートされています。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"companyId":"a","companyName":"えー"}, | |
{"companyId":"b","companyName":"びー"}, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"companyId":"a","companyName":"えー"}, | |
{"companyId":"b","companyName":"びー"}, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 配列定義:new Array より [] のほうが望ましい。とSublimeLinterに言われた。 | |
var arr = []; | |
var arr = [1, 2, 3]; | |
// 要素数を数える:Javaと並走して実装していると()をつけたくなりますが不要です。 | |
var count = arr.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 配列定義:new Array より [] のほうが望ましい。とSublimeLinterに言われた。 | |
var arr = []; | |
var arr = [1, 2, 3]; | |
// 要素数を数える:Javaと並走して実装していると()をつけたくなりますが不要です。 | |
var count = arr.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery : name属性指定 | |
let a = $('input:hidden[name="name属性"]').val(); | |
let b = $("input:hidden[name='dPreCode']").val(); | |
// jQuery : id属性指定 | |
let c = $("#dPreCode").val(); | |
let d = $('#dPreCode').val(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery : name属性指定 | |
let a = $('input:hidden[name="name属性"]').val(); | |
let b = $("input:hidden[name='dPreCode']").val(); | |
// jQuery : id属性指定 | |
let c = $("#dPreCode").val(); | |
let d = $('#dPreCode').val(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
</link>は問題外 | |
HTML5 : 「/>」は基本なしで「/>」があってもOK | |
HTML4以前 : 「/>」は基本なしで「/>」をつけるのは非推奨 | |
XHTML : 「/>」が必須 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = 何か; | |
if(a) { | |
// [](配列), {}(オブジェクト), -1(数値) | |
} else { | |
// "00"(文字:はまった・・・) | |
// ""(文字), 0(数値), false(真偽), undefined, null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = 何か; | |
if(a) { | |
// [](配列), {}(オブジェクト), -1(数値) | |
} else { | |
// "00"(文字:はまった・・・) | |
// ""(文字), 0(数値), false(真偽), undefined, null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('ローカルのJSONファイル', function(data) { | |
処理 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XMLHttpRequest cannot load ローカルのJSONファイル. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 要素作成:普通 | |
document.createElement('タグ') | |
// 要素作成:jQuery | |
$('<タグ>'); | |
// 要素の値設定:普通 | |
要素オブジェクト.setAttribute('value', 値); | |
// 要素の値設定:jQuery | |
要素オブジェクト.val(値); | |
// 要素のHTML文字設定:普通 | |
要素オブジェクト.innerHTML = 'HTML文字'; | |
// 要素のHTML文字設定:jQuery | |
要素オブジェクト.html('HTML文字'); | |
// 要素に子要素を追加:普通 | |
要素オブジェクト.appendChild(子要素オブジェクト); | |
// 要素に子要素を追加:jQuery | |
要素オブジェクト.append(子要素オブジェクト); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.each(配列かオブジェクト, function(Integer インデックスかハッシュkey, Object それぞれの値とかオブジェクト) { | |
やりたい処理; | |
return ぐるぐる回す条件(falseになれば止まる); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// これ使えます。 | |
let a = 1; | |
a++; | |
++a; | |
a--; | |
--a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (配列.indexOf(確認するもの) != -1) { | |
// 含まれている場合の処理 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// new Array より [] のほうが望ましい。とSublimeLinterに言われた。 | |
var arr = []; | |
var arr = [1, 2, 3]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment