10. jQuery Example (selects all <p> elements and adds a class of ‘italic’ to them.) $(document). ready (function() { $( ‘p’ ). addClass ( ‘italic’ ); });
11. jQuery Example (hovering over any <p> will assign the CSS property background-color with the value of “yellow” to them.) $(document). ready (function() { $( "p" ). hover (function () { $(this). css ({ backgroundColor:"yellow” }); } });
12. jQuery Example $(this). parent (). find ( “div.foo” ) … <div id= “parent” > // is parent() <a href= “#” >Foo</a> // is (this) </div> <div class= “foo” > // is find(“div.foo”) …
13. Selectors - CSS $( ‘a’ ) // Gets all anchor tags in the document $( ‘div.foobar’ ) // Gets all div’s with the class of foobar $( ‘#container’ ) // Gets the element with the ID of container
14.
15. jQuery Manipulation $(this). text ( “lorem ipsum” ) // inputs text into the selected element $(this). empty () // empties the current selected element $(this). append ( “<span>Foobar!</span>” ) // appends stuff !!
16. jQuery Events $( “p” ). hover (function() {… // when you hover over all p tags.. $( “a” ). click (function() {… // when you click on any anchor tag..
17.
Editor's Notes
I’m no an expert Focus is on designers Questions should be forwarded on to the next session about jquery for module developers We’ll be going through some basic jquery theory, do 2 practical tutorials, then save for an open discussion at the end, maybe show off what other people have done with jquery Who has worked with jquery before? Who has worked with javascript? CSS? HTML?