Skip to content

Instantly share code, notes, and snippets.

@danielpataki danielpataki/list.html
Last active May 4, 2017

Embed
What would you like to do?
Vanilla Javascript
<ul id="myList">
<li>List Item One</li>
<li>List Item Two</li>
</ul>
// jQuery Version
var firstElement = jQuery('#myList li:first');
var nextElement = firstElement.next();
// Vanilla Javascript
var firstElement = document.getElementById('myList').getElementsByTagName('li')[0];
var nextElement = firstElement.nextSibling.nextSibling;
// jQuery Version
$('#post a').addClass('postLink');
// Vanilla Javascript
var links = document.getElementById('my-element').getElementsByTagName('a');
for (i = 0; i < links.length; ++i) {
links[0].className = 'postLink';
}
// jQuery Version
$('#myElement').data('scale'); // Get
$('#myElement').data('scale', '10'); // Set
// Vanilla Javascript
document.getElementById('my-element').getAttribute('data-scale') // Get
document.getElementById('my-element').setAttribute('data-scale', '10') // Set
// jQuery Version
var element = $('#my-element');
var links = $('a.mylinks');
var articles = $('article');
// Vanilla Javascript
var element = document.getElementById('my-element');
var links = document.getElementsByClassName('mylinks');
var articles = document.getElementsByTagName('article');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.