68
edits
Changes
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....
<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.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
</code>
=What to do with selected div=
<code>
.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 <div id="other"></div>
.insertAfter('new content') // <div id="other"></div> new content
.append('new content') // <div id="other">other new content</div>
.prepend('new content') // <div id="other">new content other</div>
</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.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
</code>
=What to do with selected div=
<code>
.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 <div id="other"></div>
.insertAfter('new content') // <div id="other"></div> new content
.append('new content') // <div id="other">other new content</div>
.prepend('new content') // <div id="other">new content other</div>
</code>