jQuery Alternatives Flashcards
hide/show an element
el.style.display = ‘none’ or ‘’ or ‘block’
$el.addClass( ‘someclass’ )
if (el.classList)
el.classList.add(className);
else
el.className += ‘ ‘ + className;
$(el).after(htmlString);
el.insertAdjacentHTML(‘afterend’, htmlString);
$(parent).append(el);
someParent.appendChild(el);
$(el).children();
el.children;
$(selector).each(function(i, el){ …
var els = document.querySelectorAll( selector ); Array.prototype.forEach.call( els, function( el, i ) {...
$(el).html();
el.innerHTML or el.innerHTML = ‘some content’
$(el).text();
el.textContent or el.textContent = ‘something’;
$(el).next();
el.nextElementSibling;
$(el).prev();
el.previousElementSibling;
$(el).parent();
el.parentNode;
$(parent).prepend(el);
parent.insertBefore(el, parent.firstChild);
$(el).toggleClass(className);
if (el.classList) {
el.classList.toggle(className);
} else { // use className
$(el).on(eventName, eventHandler);
el.addEventListener(eventName, eventHandler);
$(document).append(“<div class="hello">Hi There!</div>
var d = document.createElement("div"); d.classList.add("one"); var t = document.createTextNode("Hi There!"); d.appendChild(t); document.body.appendChild(d);