37. Each!
$(‘ul#items li’).each(function(){
// In here, we can do what we want.
// Use “this” to mess with this <li>.
// Or $(this) if you want to use jQuery-fu
on it!
$(this).hide()
})
44. jQuery can CHAIN.
$(this)
.hide() // hide
.show() // show again
.css(‘float’, ‘left’) // Do some CSS
.wrap(‘<li class=“item”/>’) // wrap in <li>s
.click( // add a click
handler
function(){ // which...
alert(‘a’) // alerts ‘a‘!
45. I know this looks frightening. It just takes
practice.
47. A stroll through the
DOM
$(‘form.new_item’)
.parents(‘div.form’)
.find(‘li.description’)
.find(‘a.name’)
.children(‘span.surname’)
48. A stroll through the
DOM
$(‘form.new_item’)
.parents(‘div.form’)
.find(‘li.description’)
.find(‘a.name’)
.children(‘span.surname’)
This is called “traversing”.
67. Form Plugin
Easy validation, AJAXification of forms.
$('#myForm').ajaxForm(function() {
alert('Thank you for your comment!');
});
http://jquery.malsup.com/form/#ajaxForm
68. jquery.example.js
Gives your input fields default values!
http://github.com/mudge/jquery_example
69. Using Rails?
Use jRails!
http://github.com/aaronchi/jrails