head.daveops.net

Snippets for yer computer needs

jQuery

jQuery

No-conflict mode —————-


 var $j = jQuery.noConflict();

Append a node to the DOM


 $('#thing').append('<p>blerg</p>');'</p>')

Get first element of several

CSS pseudo-selectors $(“.stuff li:first”);

DOM traversal $(“.stuff”).first();

Searches for the closest ancestor that matches

.closest()

Objects

Use $(this) instead of this - it’s a jQuery object

Get custom data attributes from the DOM

date(name)

Get direct children from an element

$(“ul”).children(“li”);

Get parent element of a node

$(“#thing”).parent();