jQuery

Why use jQuery?

JQuery makes it easier and cleaner to use Javascript on a website

What is jQuery?

  • A lightweight, 'write less, do more' Javascript library
  • Simplifies complex tasks

Library vs Framework

How does it work?

Selector paired with an action.

$('p').hide()

Selector

Action

Selector

// Turn all <p> elements into a jQuery element
$('p')

// Turn all elements 
// with class 'test' 
// into jQuery elements
$('.test')

It can select anything using css-like syntax

  • '#test' - 
  • '.test' - 
  • 'p' - 
  • 'h1' - 
<div id="test"></div>
<div class="test"></div>
<p></p>
<h1></p>

Use Document Ready

$(document).ready(function() {
  $('p').hide();

});

JQuery

By Brett Caudill

JQuery

  • 843