JavaScript is full-featured all by itself
but there are many tasks for which a lot needs to be done
and are not in the core language
jQueryimmediately upon importing jquery-3.2.1.js, the variable jQuery will be accessible!
<head>
<meta charset="UTF-8" />
<title>Page with a style sheet</title>
<script src="http://cmpt165.csil.sfu.ca/
js/jquery-3.2.1.js" />
</head>
jquery-3.2.1.js alert function call
here
jQuery
setup = function() {
all_paragraphs = jQuery('p')
all_paragraphs.click(say_hello)
}
jquery_doc = jQuery(document)
jquery_doc.ready(setup)
"p" given to the jQuery function is a selector (or jQuery selector to be more specific)
jQuery selectorsjQuery selectors vs. CSS SelectorsjQuery extends things so you can specify things in jQuery that won't work in CSS,
for more details look at here
jQuery selector, what it gives back is a jQuery object
p_click = function() {
jQuery('#changeme').html('Somebody clicked me.')
}
h1_hover = function() {
jQuery('#changeme').html('Mouse <em>over</em> the <h1>.')
}
setup = function() {
jQuery('#changeme').click(p_click)
jQuery('h1').mouseover(h1_hover)
}
jQuery(document).ready(setup)
jQuery event attaching mechanism