http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
$("#container"); // Returns an object with a reference to a div id'd "container"$(".slides"); // Returns an object with references to every slide$("#container p"); // Returns an object with references to every <p> inside "container"$("#container").height(); // Returns a number$("#container").width(); // Returns a number$("#container").hasClass("lol"); // Boolean, returns true or false
<script type="text/javascript">
$(document).ready(function() {
$("#container").html("<strong>Document's ready, so this'll actually work.</strong>");
});
</script>
<div id="container"> </div>
$("#container").click(function() {
alert("Woah, you clicked inside this container.");
});$("#container").click(function() {
// $(this) refers to the current object we're working on. Don't repeatedly lookup!
$(this).fadeOut("fast");
});$(".myInputs").keydown(function() {
// .val() will return the value of an input or textarea
alert("You typed: " + $(this).val());
});$("#container").click(function() {
$(this).animate({width: $(this).width() + 100, height: $(this).height() + 100},
800,
function() {
alert("Animation finished!");
}
);
});
var container = $("#container");
for(var i = 0; i < 10; i++) { container.append("Tossing text inside"); }
for(var i = 0; i < 10; i++) { $("#container").append("Tossing text inside"); }