JQuery

Useful links for JQuery resources

Docs

http://api.jquery.com/

Cheat sheets

http://htmlcheatsheet.com/jquery/

https://oscarotero.com/jquery/

The basics

$(document).ready(function() {
  console.log('ready!');
});

Shorthand

$(function() {
  console.log( 'ready!' );
});

Targeting elements

$('#MyId'); // select the element with an ID of 'MyId'
$('li');      // select all list items on the page
$('ul li');   // select list items that are in unordered lists
$('.myClass'); // select all elements with a class of 'myClass'

Checking if an element exists

if ($('#MyId').length ) {
  // This code will only run if it finds a matching element
}

Get list of li and remove second item

var listItems = $( 'li' );
var secondListItem = listItems.eq( 1 );
secondListItem.remove();