$(el).addClass(className);
if (el.classList) el.classList.add(className);
else el.className += ' ' + className;
el.classList.add(className);
el.insertAdjacentHTML('afterend', htmlString);
$(el).before(htmlString);
el.insertAdjacentHTML('beforebegin', htmlString);
var children = [];
for (var i = el.children.length; i--;) { // Skip comment nodes on IE8 if (el.children[i].nodeType != 8) children.unshift(el.children[i]);
}
el !== child && el.contains(child);
$(el).find(selector).length;
el.querySelector(selector) !== null
$(selector).each(function(i, el){ });
function forEachElement(selector, fn) { var elements = document.querySelectorAll(selector); for (var i = 0; i < elements.length; i++) fn(elements[i], i);
} forEachElement(selector, function(el, i){ });
var elements = document.querySelectorAll(selector);
Array.prototype.forEach.call(elements, function(el, i){ });
while(el.firstChild) el.removeChild(el.firstChild);
$(selector).filter(filterFn);
function filter(selector, filterFn) { var elements = document.querySelectorAll(selector); var out = []; for (var i = elements.length; i--;) { if (filterFn(elements[i])) out.unshift(elements[i]); } return out;
} filter(selector, filterFn);
Array.prototype.filter.call(document.querySelectorAll(selector), filterFn);
el.querySelectorAll(selector);
$('.my #awesome selector');
document.querySelectorAll('.my #awesome selector');
el.getAttribute('tabindex');
$('<div>').append($(el).clone()).html();
// Varies based on the properties being retrieved, some can be retrieved from el.currentStyle
// https://github.com/jonathantneal/Polyfills-for-IE8/blob/master/getComputedStyle.js
getComputedStyle(el)[ruleName];
el.textContent || el.innerText
$(el).hasClass(className);
if (el.classList) el.classList.contains(className);
else new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
el.classList.contains(className);
var matches = function(el, selector) { var _matches = (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector); if (_matches) { return _matches.call(el, selector); } else { var nodes = el.parentNode.querySelectorAll(selector); for (var i = nodes.length; i--;) { if (nodes[i] === el) return true; } return false; }
}; matches(el, '.my-class');
var matches = function(el, selector) { return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
}; matches(el, '.my-class');
// nextSibling can include text nodes
function nextElementSibling(el) { do { el = el.nextSibling; } while ( el && el.nodeType !== 1 ); return el;
} el.nextElementSibling || nextElementSibling(el);
var rect = el.getBoundingClientRect(); { top: rect.top + document.body.scrollTop, left: rect.left + document.body.scrollLeft
}
function outerHeight(el) { var height = el.offsetHeight; var style = el.currentStyle || getComputedStyle(el); height += parseInt(style.marginTop) + parseInt(style.marginBottom); return height;
} outerHeight(el);
function outerHeight(el) { var height = el.offsetHeight; var style = getComputedStyle(el); height += parseInt(style.marginTop) + parseInt(style.marginBottom); return height;
} outerHeight(el);
function outerWidth(el) { var width = el.offsetWidth; var style = el.currentStyle || getComputedStyle(el); width += parseInt(style.marginLeft) + parseInt(style.marginRight); return width;
} outerWidth(el);
function outerWidth(el) { var width = el.offsetWidth; var style = getComputedStyle(el); width += parseInt(style.marginLeft) + parseInt(style.marginRight); return width;
} outerWidth(el);
{left: el.offsetLeft, top: el.offsetTop}
var offset = el.offset(); { top: offset.top - document.body.scrollTop, left: offset.left - document.body.scrollLeft
}
el.getBoundingClientRect()
parent.insertBefore(el, parent.firstChild);
// prevSibling can include text nodes
function previousElementSibling(el) { do { el = el.previousSibling; } while ( el && el.nodeType !== 1 ); return el;
} el.previousElementSibling || previousElementSibling(el);
el.previousElementSibling
$(el).replaceWith(string);
$(el).attr('tabindex', 3);
el.setAttribute('tabindex', 3);
$(el).css('border-width', '20px');
// Use a class if possible
el.style.borderWidth = '20px';
if (el.textContent !== undefined) el.textContent = string;
else el.innerText = string;
var siblings = Array.prototype.slice.call(el.parentNode.children); for (var i = siblings.length; i--;) { if (siblings[i] === el) { siblings.splice(i, 1); break; }
}
Array.prototype.filter.call(el.parentNode.children, function(child){ return child !== el;
});
$(el).toggleClass(className);
if (el.classList) { el.classList.toggle(className);
} else { var classes = el.className.split(' '); var existingIndex = -1; for (var i = classes.length; i--;) { if (classes[i] === className) existingIndex = i; } if (existingIndex >= 0) classes.splice(existingIndex, 1); else classes.push(className); el.className = classes.join(' ');
}
if (el.classList) { el.classList.toggle(className);
} else { var classes = el.className.split(' '); var existingIndex = classes.indexOf(className); if (existingIndex >= 0) classes.splice(existingIndex, 1); else classes.push(className); el.className = classes.join(' ');
}
el.classList.toggle(className);