jQuery is a library, or set of helpful add-ons, to the JavaScript programming language.
- basic syntax:
$(document).ready(function() {
$("#id").fadeOut(1000);
});
- link to html:
<head>
<script type="text/javascript" src="script.js"></script>
</head>
- about
$(document).ready();
:
$()
tell that jQuery things are about to happen- Putting
document
between the parentheses tells us that we’re about to work on the HTML document itself. .ready();
is a function, or basic action, in jQuery. It says “hey, I’m going to do stuff as soon as the HTML document is ready!”- Whatever goes in .ready()’s parentheses is the jQuery event that occurs as soon as the HTML document is ready.
- So,
$(document).ready(something);
says: “when the HTML document is ready, do something!”
- Insert Elements:
.append()
inserts the specified element as the last child of the target element..prepend()
inserts the specified element as the first child of the target element.