JavaScript
altJQuery

jQueryを標準APIに置き換える

More than 3 years have passed since last update.

jQuery追放作業用の備忘録です。


NG:不明


title取得

$(el).attr('title');

el.title;


outerWidth

$(el).outerWidth();

el.offsetWidth


outerHeight

$(el).outerHeight();

el.offsetHeight


style設定

$(el).css('border-width', '20px');

el.style.borderWidth = '20px';


NG:IE8


子供をeach

$(el).chidlren().each(function(index, element){

// do anything...
});

Array.prototype.forEach.call(el.children, function(element, index){

// do anything...
});


next

$(el).next();

el.nextElementSibling


prev

$(el).prev();

el.previousElementSibling


NG:IE9


hasClass

$(el).hasClass(className);

el.classList.contains(className);


参考リンク

You Might Not Need jQuery