JQuery intro

Revision as of 13:59, 12 June 2010 by Kenirwin (Talk | contribs) (New page: <code> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js"></script> <code> =Selectors= <code> $('a') // select anchor tags $('a[href*=code4lib....)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Revision as of 13:59, 12 June 2010 by Kenirwin (Talk | contribs) (New page: <code> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js"></script> <code> =Selectors= <code> $('a') // select anchor tags $('a[href*=code4lib....)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js"></script> <code>

Selectors

<code> $('a') // select anchor tags

$('a[href*=code4lib.org]') // just the ones with c4l

$('#section1') // where id=section1

$('.hidden') // where class=hidden

$('ul#dictionary li') // list items in a particular list

$('body > div') // each div that's a first-level child


What to do with selected div

.text() // grab the text

.text('new text') // overwrite the text

.html() // grab the html INSIDE

.attr('id') // grab the value of the ID attribute

.addClass('purple') // add a class

.removeClass('menu') // remove

.insertBefore('new content') // new content
.insertAfter('new content') //
new content .append('new content') //
other new content
.prepend('new content') //
new content other