Changes

Jump to: navigation, search

JQuery intro

1,095 bytes added, 13:59, 12 June 2010
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>
68
edits

Navigation menu