jQuery
- jQuery's motto is write less, do more
- jQuery was originally written by John Rezig
- It is now maintained by a strong community
- There is even a yearly jQuery conference in Toronto
- http://jquery.com
Define what a library vs framework is
- Library is set of methods to be utilized
- framework is a combination of multiple libraries and tools.
- Various libraries include:
List primary components of jQuery
- DOM traversal
- Event Handling
- Ajax interactions
- Event Handling
How to include jQuery into an app
- Include using CDN or local file
- See the Installing jQuery with NPM section below
- CDNS:
Select existing DOM nodes
Example |
... in jQuery |
Elements |
$("element")`, `$("#id")` or `$(".class") |
Descendants |
$("#id descendant") |
Children |
$(".class > child") |
Multiple |
$("#id1, #id2, #id3") |
Pseudo-selectors |
$("li :first") |
Build and append custom DOM nodes
.append()
.appendTo()
.text()
.prepend()
.prependTo()
.html()
Trigger and listen to events
$(selector).click(function() {
});
Using jQuery in your html head element
- In your index.html file, add:
<script type='text/javascript' src='scripts/jquery.js'></script>
Resources & Further Reading