This file contains hidden or 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
$.fn.tab = function (options) { | |
options = $.extend({}, { | |
activeClass: 'is-active', | |
defaultTab: 0, | |
onInit: function ($panels, $tabs) { | |
$.noop(); | |
}, | |
onChange: function ($panels, $panel, $tab) { | |
$.noop(); | |
} |
This file contains hidden or 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
/* IE6 以下 */ | |
* html .selector {} | |
.selector { _color: #FFF; } | |
/* IE7 */ | |
*:first-child+html .selector {} | |
*+html .selector {} | |
/* IE6, 7 */ | |
.selector { /color: #FFF; } |
This file contains hidden or 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
$.ajax({ | |
url: 'data.xml', | |
type: 'GET', | |
dataType: 'xml', | |
timeout: 20000, | |
error: function () { | |
}, | |
success: function (xml) { | |
var xmlTree = $(xml); | |
} |
This file contains hidden or 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
// ページの上から指定した位置まで移動する | |
scrollTo(0, 400); | |
document.body.scrollTop = 400; | |
// jQueryを使用した方法 | |
$('html, body').scrollTop(400); | |
// 現在の位置から指定した距離までスクロールする | |
scrollBy(0, 100); |
This file contains hidden or 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
window.addEventListener("load", function() { | |
setTimeout(scrollBy, 100, 0, 1); | |
}, false); | |
// setTimeout()は | |
// 第三引数以降で、 | |
// 第一引数で渡した関数に渡す値を | |
// 指定できる | |
// scrollByではなくscrollToを使う方法が |
This file contains hidden or 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
function fadeIn (elm) { | |
var last = +new Date(); | |
elm.style.opacity = 0; | |
tick(); | |
function tick () { | |
elm.style.opacity = +el.style.opacity + (new Date() - last) / 400; | |
last = +new Date(); | |
if (+elm.style.opacity < 1) { | |
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16); | |
} |
This file contains hidden or 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
// クラスの付与 | |
function addClass (elm, className) { | |
if (elm.classList) { | |
elm.classList.remove(className); | |
} else { | |
elm.className += ' ' + className; | |
} | |
} | |
// クラスの削除 |
This file contains hidden or 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
function deepExtend (out) { | |
out = out || {}; | |
for (var i = 1; i < arguments.length; i++) { | |
var obj = arguments[i]; | |
if (!obj) { | |
continue; | |
} | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
if (typeof obj[key] === 'object') { |
This file contains hidden or 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
// 要素の追加 | |
elm.insertAdjacentHTML('afterend', htmlString); | |
elm.insertAdjacentHTML('beforebegin', htmlString); | |
parent.appendChild(elm); | |
parent.insertBefore(el, parent.firstChild); | |
// トラヴァース | |
document.querySelectorAll('.my #awesome selector'); // セレクタで指定した要素を、ドキュメント全体から取得 | |
elm.querySelectorAll(selector); // セレクタで指定した要素を、子孫から取得 | |
elm.children; // 子要素 |