<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
Execute a function within the context of every matched element.
¸ÅÄ¡ µÇ¾îÁø ¸ðµç ¿ø¼Ò¿¡ ´ëÇØ ÁÖ¾îÁø Äݹé ÇÔ¼ö¸¦ ½ÇÇàÇÑ´Ù. ·çÇÁÀÇ ÀǹÌÀÌ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
5. size( ) Returns: Number
size( ), ½ÇÇàÈÄ ¼ýÀÚ¸¦ ¹Ýȯ
The number of elements in the jQuery object.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒµéÀÇ °¹¼ö¸¦ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$(document.body).click(function () {
$(document.body).append($("<div>"));
var n = $("div").size();
$("span").text("There are " + n + " divs." +
"Click to add more.");
}).click(); // trigger the click to start
6. length Returns: Number
length, ½ÇÇàÈÄ ¼ýÀÚ¸¦ ¹Ýȯ
The number of elements in the jQuery object.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒµéÀÇ °¹¼ö¸¦ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$(document.body).click(function () {
$(document.body).append($("<div>"));
var n = $("div").length;
$("span").text("There are " + n + " divs." +
"Click to add more.");
}).trigger('click'); // trigger the click to start
Access all matched DOM elements.
¸ÅÄ¡µÇ´Â ¸ðµç ¹®¼ ¿ø¼ÒµéÀ» ¹è¿·Î ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function disp(divs) {
var a = [];
for (var i = 0; i < divs.length; i++) {
a.push(divs[i].innerHTML);
}
$("span").text(a.join(" "));
}
8. get( index ) Returns: Element
get( À妽º ), ½ÇÇàÈÄ ¸ÅÄ¡ µÇ´Â ¿ø¼Ò¸¦ ¹Ýȯ
Access a single matched DOM element at a specified index in the matched set.
¸ÅÄ¡µÇ´Â ¿ø¼Òµé Áß ÁÖ¾îÁø À妽º¿¡ ÇØ´çÇÏ´Â ÇϳªÀÇ ¿ø¼Ò¸¸ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("*", document.body).click(function (e) {
e.stopPropagation();
var domEl = $(this).get(0);
$("span:first").text("Clicked on - " + domEl.tagName);
});
});
</script>
<style>
span { color:red; }
div { background:yellow; }
</style>
</head>
<body>
<span> </span>
<p>In this paragraph is an <span>important</span> section</p>
<div><input type="text" /></div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div").click(function () {
// this is the dom element clicked
var index = $("div").index(this);
$("span").text("That was div index #" + index);
});
Extends the jQuery element set to provide new methods (used to make a typical jQuery plugin).
Á¦ÀÌÄõ¸®¿¡ »õ·Î¿î ÇÔ¼ö¸¦ È®ÀåÇÑ´Ù.(Ç÷¯±×ÀÎÀ¸·Î ¸¸µé¾î »ç¿ëÇÑ´Ù.)
Matches all descendant elements specified by "descendant" of elements specified by "ancestor".
ÁÖ¾îÁø Á¶»ó¿¡ ÁÖ¾îÁø ÀÚ¼ÕÀ» °¡Áø ¸ðµç ÀÚ¼ÕÀ» ¹è¿·Î ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("form input").css("border", "2px dotted blue");
});
</script>
<style>
body { font-size:14px; }
form { border:2px green solid; padding:2px; margin:0;
background:#efe; }
div { color:red; }
fieldset { margin:1px; padding:3px; }
</style>
</head>
<body>
<form>
<div>Form is surrounded by the green outline</div>
<label>Child:</label>
<input name="name" />
<fieldset>
<label>Grandchild:</label>
<input name="newsletter" />
</fieldset>
</form>
Sibling to form: <input name="none" />
</body>
</html>
Matches all child elements specified by "child" of elements specified by "parent".
ÁÖ¾îÁø Á¶»ó¿¡ Æ÷ÇÔµÈ ÁÖ¾îÁø ÀÚ¼Õ¿¡ ¸ÅÄ¡µÇ´Â ÀÏ´Ü°è Àڼյ鸸 ¸ðµÎ ¹è¿·Î ¹Ýȯ
Matches all next elements specified by "next" that are next to elements specified by "prev".
ÁÖ¾îÁø ¾Õ¿ø¼Ò¿Í µÚ¿ø¼Ò¿¡ ¼øÂ÷ÀûÀ¸·Î ¸ÅÄ¡ µÇ´Â µÚ¿ø¼ÒµéÀ» ¸ðµÎ ¹è¿·Î ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("label + input").css("color", "blue").val("Labeled!")
});
</script>
Matches all sibling elements after the "prev" element that match the filtering "siblings" selector.
ÁÖ¾îÁø ¾Õ¿ø¼Ò¿Í ÇüÁ¦ÀÎ µÚ¿ø¼Ò¸¦ ã¾Æ ¸ðµÎ ¹è¿·Î ¹Ýȯ
Filters out all elements matching the given selector.
ÁÖ¾îÁø °Í¿¡ ÇØ´çÇÏÁö ¾Ê´Â ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("tr:even").css("background-color", "#bbbbff");
});
</script>
<style>
table {
background:#eeeeee;
}
</style>
</head>
<body>
<table border="1">
<tr><td>Row with Index #0</td></tr>
<tr><td>Row with Index #1</td></tr>
<tr><td>Row with Index #2</td></tr>
<tr><td>Row with Index #3</td></tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("tr:odd").css("background-color", "#bbbbff");
});
</script>
<style>
table {
background:#f3f7f5;
}
</style>
</head>
<body>
<table border="1">
<tr><td>Row with Index #0</td></tr>
<tr><td>Row with Index #1</td></tr>
<tr><td>Row with Index #2</td></tr>
<tr><td>Row with Index #3</td></tr>
</table>
</body>
</html>
15. :eq(index) Returns: Element
eq(À妽º), ½ÇÇàÈÄ ¿ø¼Ò ¹Ýȯ
Matches a single element by its index.
¸ÅÄ¡µÈ ¿ø¼Òµé Áß¿¡¼ ÁÖ¾îÁø À妽º¿¡ ¸ÅÄ¡µÇ´Â ¿ø¼Ò ÇÑ°³¸¦ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("td:eq(2)").css("text-decoration", "blink");
});
</script>
Matches all elements that are currently being animated.
¸ÅÄ¡µÈ ¿ø¼Òµé Áß¿¡¼ ¾Ö´Ï¸ÞÀ̼ÇÀÌ µ¿ÀÛÇÏ°í ÀÖ´Â °ÍµéÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#run").click(function(){
$("div:animated").toggleClass("colored");
});
function animateIt() {
$("#mover").slideToggle("slow", animateIt);
}
animateIt();
Matches elements which contain at least one element that matches the specified selector.
¸ÅÄ¡µÈ ¿ø¼Òµé Áß¿¡¼ ÁÖ¾îÁø °ÍÀ» Æ÷ÇÔÇÏ´Â °ÍÀ» ¸ðµÎ ¹è¿·Î ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div:has(p)").addClass("test");
});
</script>
<style>
.test{ border: 3px inset red; }
</style>
</head>
<body>
<div><p>Hello in a paragraph</p></div>
<div>Hello again! (with no paragraph)</div>
</body>
</html>
Matches all elements that are hidden, or input elements of type "hidden".
º¸ÀÌÁö ¾Ê´Â ¸ðµç °ÍµéÀ» ¹ÝȯÇÑ´Ù. none hidden µî, Ãß°¡·Î inputÀ» ÁöÁ¤Çϸé ÀÎDzŸÀÔÀÌ È÷µçÀΰ͸¸ ¹Þ¾Æ¿Â´Ù
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
// in some browsers :hidden includes head, title, script, etc... so limit to body
$("span:first").text("Found " + $(":hidden", document.body).length +
" hidden elements total.");
$("div:hidden").show(3000);
$("span:last").text("Found " + $("input:hidden").length + " hidden inputs.");
Matches all elements that are visible.
º¸ÀÌ´Â °ÍµéÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Matches elements that have the specified attribute.
ÁÖ¾îÁø ¼Ó¼ºÀ» °¡Áø °ÍµéÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Matches elements that have the specified attribute with a certain value.
ÁÖ¾îÁø ¼Ó¼º°ú ÁÖ¾îÁø °ªÀÌ ÀÏÄ¡ ÇÏ´Â ¸ðµç°ÍµéÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input[name='newsletter']").next().text(" is newsletter");
});
</script>
Matches elements that don't have the specified attribute with a certain value.
ÁÖ¾îÁø ¼Ó¼º°ú ÁÖ¾îÁø °ªÀÌ ÀÏÄ¡ ÇÏÁö ¾Ê´Â ¸ðµç°ÍµéÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input[name!='newsletter']").next().text(" is not newsletter");
});
</script>
Matches elements that have the specified attribute and it starts with a certain value.
ÁÖ¾îÁø ¼Ó¼ºÀ» °¡Áö¸ç °ªÀÌ ÁÖ¾îÁø °ªÀ¸·Î ½ÃÀ۵Ǵ ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input[name^='news']").val("news here!");
});
</script>
Matches elements that have the specified attribute and it ends with a certain value.
ÁÖ¾îÁø ¼Ó¼ºÀ» °¡Áö¸ç °ªÀÌ ÁÖ¾îÁø °ªÀ¸·Î ³¡³ª´Â ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input[name$='letter']").val("a letter");
});
</script>
Matches elements that have the specified attribute and it contains a certain value.
ÁÖ¾îÁø ¼Ó¼ºÀ» °¡Áö¸ç °ªÀÌ ÁÖ¾îÁø °ªÀ» Æ÷ÇÔÇÏ´Â ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input[name*='man']").val("has man in it!");
});
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input[id][name$='man']").val("only this one");
});
</script>
Matches the first child of its parent.
ù¹ø° ÀڽĿ¡ ¸ÅÄ¡µÇ´Â ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Matches the last child of its parent.
¸¶Áö¸· ÀڽĿ¡ ¸ÅÄ¡µÇ´Â ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Matches all input, textarea, select and button elements.
ÀÎDz, ÅؽºÆ®¿¡¸®¾î, ¼¿·ºÆ®¹Ú½º, ¹öÆ°µéÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var allInputs = $(":input");
var formChildren = $("form > *");
$("div").text("Found " + allInputs.length + " inputs and the form has " +
formChildren.length + " children.")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type text.
ÀÎDzŸÀÔÀÌ ÅؽºÆ®ÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":text").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type password.
ÀÎDzŸÀÔÀÌ Æнº¿öµåÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":password").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type radio.
ÀÎDzŸÀÔÀÌ ·¹µð¿ÀÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":radio").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":checkbox").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type submit.
ÀÎDzŸÀÔÀÌ ¼ºê¹ÔÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":submit").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type image.
ÀÎDzŸÀÔÀÌ À̹ÌÁöÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":image").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type reset.
ÀÎDzŸÀÔÀÌ ¸®¼ÂÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":reset").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type button.
ÀÎDzŸÀÔÀÌ ¹öÆ°ÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":button").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all input elements of type file.
ÀÎDzŸÀÔÀÌ ÆÄÀÏÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var input = $(":file").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
Matches all elements that are hidden, or input elements of type "hidden".
ÀÎDzŸÀÔÀÌ È÷µçÀÎ °ÍÀ» ¸ðµÎ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
// in some browsers :hidden includes head, title, script, etc... so limit to body
$("span:first").text("Found " + $(":hidden", document.body).length +
" hidden elements total.");
$("div:hidden").show(3000);
$("span:last").text("Found " + $("input:hidden").length + " hidden inputs.");
Matches all elements that are enabled.
È°¼ºÈµÈ ¸ðµç °ÍµéÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input:enabled").val("this is it");
});
</script>
Matches all elements that are disabled.
ºñÈ°¼ºÈµÈ ¸ðµç °ÍµéÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("input:disabled").val("this is it");
});
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function countChecked() {
var n = $("input:checked").length;
$("div").text(n + (n == 1 ? " is" : " are") + " checked!");
}
countChecked();
$(":checkbox").click(countChecked);
Matches all elements that are selected.
¼±ÅÃµÈ ¸ðµç °ÍÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
1. attr( name ) Returns: Object
¼Ó¼º ½ÇÇàÈÄ °´Ã¼ ¹Ýȯ
Access a property on the first matched element. This method makes it easy to retrieve a property value from the first matched element. If the element does not have an attribute with such a name, undefined is returned.
ÁÖ¾îÁø ¼Ó¼º¸íÀÇ °ªÀ» °¡Á®¿È, ¸ÅÄ¡µÇ´Â ù¹ø° °Í¸¸ °¡Á®¿È
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var title = $("em").attr("title");
$("div").text(title);
});
</script>
<style>
em { color:blue; font-weight;bold; }
div { color:red; }
</style>
</head>
<body>
<p>
Once there was a <em title="huge, gigantic">large</em> dinosaur...
</p>
The title of the emphasis is:<div></div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Remove an attribute from each of the matched elements.
ÁÖ¾îÁø À̸§°ú ¸ÅÄ¡µÇ´Â ¼Ó¼ºÀ» Á¦°Å
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Adds the specified class if it is not present, removes the specified class if it is present.
ÁÖ¾îÁø Ŭ·¡½º¸¦ Ãß°¡ »èÁ¦¸¦ ¹Ýº¹ÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Get the html contents (innerHTML) of the first matched element. This property is not available on XML documents (although it will work for XHTML documents).
¼±ÅõǾîÁø °´Ã¼ÀÇ htmlÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").click(function () {
var htmlStr = $(this).html();
$(this).text(htmlStr);
});
});
</script>
<style>
p { margin:8px; font-size:20px; color:blue;
cursor:pointer; }
b { text-decoration:underline; }
button { cursor:pointer; }
</style>
</head>
<body>
<p>
<b>Click</b> to change the <span id="tag">html</span>
</p>
<p>
to a <span id="text">text</span> node.
</p>
<p>
This <button name="nada">button</button> does nothing.
</p>
</body>
</html>
10. html( val ) Returns: jQuery
½ÇÇàÈÄ jQuery °´Ã¼¸¦ ¹Ýȯ
Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents).
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ÁÖ¾îÁø htmlÀ» ³Ö´Â´Ù.
Get the text contents of all matched elements.
¼±ÅõǾîÁø °´Ã¼ÀÇ ¹®ÀÚ¿À» ¹ÝȯÇÑ´Ù. ű״ Á¦¿ÜµÈ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var str = $("p:first").text();
$("p:last").html(str);
});
</script>
<style>
p { color:blue; margin:8px; }
b { color:red; }
</style>
</head>
<body>
<p><b>Test</b> Paragraph.</p>
<p></p>
</body>
</html>
12. text( val ) Returns: jQuery
½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Set the text contents of all matched elements.
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ÁÖ¾îÁø ÅؽºÆ®¸¦ Áý¾î³Ö´Â´Ù. htmlÀ» ³Ö´Â´Ù Çصµ ÅؽºÆ®È µÈ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").text("<b>Some</b> new text.");
});
</script>
<style>
p { color:blue; margin:8px; }
</style>
</head>
<body>
<p>Test Paragraph.</p>
</body>
</html>
Get the content of the value attribute of the first matched element.
ù¹ø° ¸ÅÄ¡µÇ´Â ¿ø¼ÒÀÇ °ªÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function displayVals() {
var singleValues = $("#single").val();
var multipleValues = $("#multiple").val() || [];
$("p").html("<b>Single:</b> " +
singleValues +
" <b>Multiple:</b> " +
multipleValues.join(", "));
}
Set the value attribute of every matched element.
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ÁÖ¾îÁø °ªÀ» Àû¿ëÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("button").click(function () {
var text = $(this).text();
$("input").val(text);
});
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Reduce the set of matched elements to a single element.
¸ÅÄ¡µÇ´Â ¿ø¼ÒÁß À妽º¿Í ÀÏÄ¡ÇÏ´Â °Í Çϳª¸¸ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Checks the current selection against a class and returns true, if at least one element of the selection has the given class.
¸ÅÄ¡µÇ´Â ¿ø¼Ò¿¡ ÁÖ¾îÁø Ŭ·¡½º°¡ Á¸ÀçÇϸé Âü, ¾Æ´Ï¸é °ÅÁþÀ» ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Removes all elements from the set of matched elements that do not match the specified expression(s).
¸ÅÄ¡µÇ´Â ¿ø¼ÒµéÁß ÇØ´ç ÇÊÅÍ Ç¥Çö¿¡ ¸ÂÁö ¾Ê´Â °ÍµéÀº Á¦°ÅÇÏ°í ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Removes all elements from the set of matched elements that does not match the specified function.
¸ÅÄ¡µÇ´Â ¿ø¼ÒµéÁß ÇØ´ç ÇÊÅÍ ÇÔ¼ö¿¡ ¸ÂÁö ¾Ê´Â °ÍµéÀº Á¦°ÅÇÏ°í ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div").one('click', function () {
if ($(this).is(":first-child")) {
$("p").text("It's the first div.");
} else if ($(this).is(".blue,.red")) {
$("p").text("It's a blue or red div.");
} else if ($(this).is(":contains('Peter')")) {
$("p").text("It's Peter!");
} else {
$("p").html("It's nothing <em>special</em>.");
}
$("p").hide().slideDown("slow");
$(this).css({"border-style": "inset", cursor:"default"});
});
Translate a set of elements in the jQuery object into another set of values in an array (which may, or may not, be elements).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Removes elements matching the specified expression from the set of matched elements.
¸ÅÄ¡µÇ´Â ¿ø¼ÒµéÁß Ç¥Çö½Ä°ú ÀÏÄ¡ ÇÏ´Â ¿ø¼Ò´Â Á¦°Å ÇÏ°í ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
18. slice( start, end ) Returns: jQuery
Selects a subset of the matched elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼Òµé Áß¿¡¼ ÇØ´ç ½ÃÀÛÀ妽º¿Í ³¡ À妽ºÀÇ ¹üÀ§¿¡ ÀÖ´Â À妽ºÀÇ ¿ø¼ÒµéÀ» ¸ðµÎ ¹è¿·Î ¹ÝȯÇÑ´Ù.
³¡ À妽º¸¦ ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é ½ÃÀÛÀ妽º ºÎÅÍ ³¡±îÁö ¹è¿·Î ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function colorEm() {
var $div = $("div");
var start = Math.floor(Math.random() *
$div.length);
var end = Math.floor(Math.random() *
($div.length - start)) +
start + 1;
if (end == $div.length) end = undefined;
$div.css("background", "");
if (end)
$div.slice(start, end).css("background", "yellow");
else
$div.slice(start).css("background", "yellow");
Adds more elements, matched by the given expression, to the set of matched elements.
¸ÅÄ¡µÈ ¿ø¼Ò¿¡ »õ·Î¿î ¿ø¼Ò³ª ¿ø¼ÒµéÀ» Ãß°¡ÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Get a set of elements containing all of the unique children of each of the matched set of elements.
¼±ÅõǾîÁø ¿ø¼ÒÀÇ ÀڽĵéÀ» ¹Ýȯ
ÀÌÇØ°¡ Àß ¾ÈµÊ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#container").click(function (e) {
$("*").removeClass("hilite");
var $kids = $(e.target).children();
var len = $kids.addClass("hilite").length;
Find all the child nodes inside the matched elements (including text nodes), or the content document, if the element is an iframe.
¸ÅÄ¡µÈ ¿ø¼ÒµéÁß¿¡¼ ºñ¾îÀÖÁö ¾Ê´Â ÀڽĵéÀ» ¸ðµÎ °¡Á®¿È
ÀÌÇØ°¡ Àß ¾ÈµÊ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").contents().not("[@nodeType=1]").wrap("<b/>");
});
</script>
</head>
<body>
<p>Hello <a href="Johnhttp://ejohn.org/">John</a>, how are you doing?</p>
</body>
</html>
Searches for all elements that match the specified expression. This method is a good way to find additional descendant elements with which to process.
¸ÅÄ¡µÇ¾îÁø ¿ø¼Òµé Áß¿¡¼ ÁÖ¾îÁø °Í¿¡ ¸ÅÄ¡µÇ´Â °ÍÀ» ã¾Æ ±×°ÍµéÀ» ¸ðµÎ ¹è¿·Î ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").find("span").css('color','red');
});
</script>
</head>
<body>
<p><span>Hello</span>, how are you?</p>
<p>Me? I'm <span>good</span>.</p>
</body>
</html>
Get a set of elements containing the unique next siblings of each of the matched set of elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼Ò¿Í ÇüÁ¦ °ü°èÀÎ ¹Ù·Î ´ÙÀ½ ¿ø¼Ò¸¦ ã¾Æ °´Ã¼·Î ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("button").click(function () {
var txt = $(this).text();
$(this).next().text(txt);
});
Get a set of elements containing the unique parents of the matched set of elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒÀÇ À¯ÀÏÇÑ ºÎ¸ð¸¦ ã¾Æ °´Ã¼·Î ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Get a set of elements containing the unique ancestors of the matched set of elements (except for the root element).
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒÀÇ À¯ÀÏÇÑ Á¶»óµéÀ» ã¾Æ °´Ã¼·Î ¹ÝȯÇÑ´Ù.
The matched elements can be filtered with an optional expression.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Get a set of elements containing all of the unique siblings of each of the matched set of elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒµéÀÇ ¸ðµç ÇüÁ¦ ¿ø¼ÒµéÀ» ã¾Æ ¹ÝȯÇÑ´Ù.
Can be filtered with an optional expressions.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var len = $(".hilite").siblings()
.css("color", "red")
.length;
$("b").text(len);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Revert the most recent 'destructive' operation, changing the set of matched elements to its previous state (right before the destructive operation).
ÇöÀç º¸´Ù ÀÌÀüÀÇ ¸ÅÄ¡»óÅ·Πµ¹¾Æ°¡¼ °´Ã¼¸¦ ¹Ýȯ
Àß ÀÌÇØ°¡ ¾ÈµÊ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
jQuery.fn.showTags = function (n) {
var tags = this.map(function () {
return this.tagName;
})
.get().join(", ");
$("b:eq(" + n + ")").text(tags);
return this;
};
});
</script>
<style>
p, div { margin:1px; padding:1px; font-weight:bold;
font-size:16px; }
div { color:blue; }
b { color:red; }
</style>
</head>
<body>
<p>
Hi there <span>how</span> are you <span>doing</span>?
</p>
<p>
This <span>span</span> is one of
several <span>spans</span> in this
<span>sentence</span>.
</p>
<div>
Tags in jQuery object initially: <b></b>
</div>
<div>
Tags in jQuery object after find: <b></b>
</div>
<div>
Tags in jQuery object after end: <b></b>
</div>
</body>
</html>
Get the html contents (innerHTML) of the first matched element. This property is not available on XML documents (although it will work for XHTML documents).
¸ÅÄ¡µÇ¾îÁø ù¹ø° ¿ø¼ÒÀÇ htmlÀ» °¡Á®¿Í¼ ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").click(function () {
var htmlStr = $(this).html();
$(this).text(htmlStr);
});
});
</script>
<style>
p { margin:8px; font-size:20px; color:blue;
cursor:pointer; }
b { text-decoration:underline; }
button { cursor:pointer; }
</style>
</head>
<body>
<p>
<b>Click</b> to change the <span id="tag">html</span>
</p>
<p>
to a <span id="text">text</span> node.
</p>
<p>
This <button name="nada">button</button> does nothing.
</p>
</body>
</html>
2. html( val ) Returns: jQuery
html( val ), ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents).
Get the text contents of all matched elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒÀÇ Å±׸¦ Á¦¿ÜÇÑ ¹®ÀÚ¿¸¸ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var str = $("p:first").text();
$("p:last").html(str);
});
</script>
<style>
p { color:blue; margin:8px; }
b { color:red; }
</style>
</head>
<body>
<p><b>Test</b> Paragraph.</p>
<p></p>
</body>
</html>
4. text( val ) Returns: jQuery
text( val ), ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Set the text contents of all matched elements.
¸ÅÄ¡µÈ ¿ø¼Òµé¿¡ ÁÖ¾îÁø ¹®ÀÚ¿À» »ðÀÔÇÏ°í °´Ã¼¸¦ ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").text("<b>Some</b> new text.");
});
</script>
<style>
p { color:blue; margin:8px; }
</style>
</head>
<body>
<p>Test Paragraph.</p>
</body>
</html>
Append all of the matched elements to another, specified, set of elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒµéÀÇ ³»¿ëµéÀ» ÁÖ¾îÁø Á¶°Ç¿¡ ¸Â´Â ¿ø¼Ò¿¡ Ãß°¡·Î »ðÀÔÇÑÈÄ °´Ã¼ ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("span").appendTo("#foo"); // check append() examples
});
</script>
<style>#foo { background:yellow; }</style>
</head>
<body>
<span>I have nothing more to say... </span>
<div id="foo">FOO! </div>
</body>
</html>
Prepend all of the matched elements to another, specified, set of elements.
¸Å칮µÇ¾îÁø ¿ø¼ÒÀÇ ³»¿ëÀ» ÁÖ¾îÁø °Í¿¡ ¸ÅÄ¡µÇ´Â ¿ø¼ÒÀÇ ¸Ç¾Õ¿¡ Ãß°¡ »ðÀÔÇÑÈÄ °´Ã¼¸¦ ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("span").prependTo("#foo"); // check prepend() examples
});
</script>
<style>div { background:yellow; }</style>
</head>
<body>
<div id="foo">FOO!</div>
<span>I have something to say... </span>
</body>
</html>
Wrap all the elements in the matched set into a single wrapper element.
¸ÅÄ¡µÇ¾îÁø ¿ø¼ÒµéÀ» ÁÖ¾îÁø °Í¿¡ ¸ÅÄ¡µÇ´Â °ÍÀ¸·Î Çϳª·Î °¨½Ñ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").wrapAll(document.createElement("div"));
});
</script>
<style>
div { border: 2px solid blue; }
p { background:yellow; margin:4px; }
</style>
</head>
<body>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
</body>
</html>
17. wrapInner( html ) Returns: jQuery
wrapInner( html ), ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Wrap the inner child contents of each matched element (including text nodes) with an HTML structure.
¸ÅÄ¡µÇ¾îÁø ¿ø¼Ò ¼ÓÀÇ ³»¿ëÀ» ÁÖ¾îÁø °ÍÀ¸·Î °¨½Ñ´Ù
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("body").wrapInner("<div><div><p><em><b></b></em></p></div></div>");
});
</script>
<style>
div { border:2px green solid; margin:2px; padding:2px; }
p { background:yellow; margin:2px; padding:2px; }
</style>
</head>
<body>
Plain old text, or is it?
</body>
</html>
Wrap the inner child contents of each matched element (including text nodes) with a DOM element.
¸ÅÄ¡µÇ¾îÁø ¿ø¼Ò ¼ÓÀÇ ³»¿ëÀ» ÁÖ¾îÁø °Í¿¡ ¸ÅÄ¡µÈ°ÍÀ¸·Î °¨½Ñ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").wrapInner(document.createElement("b"));
});
</script>
<style>p { background:#9f9; }</style>
</head>
<body>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
</body>
</html>
Replaces all matched elements with the specified HTML or DOM elements.
¸ÅÄ¡µÇ¾îÁø ¿ø¼Ò¸¦ ÁÖ¾îÁø ³»¿ë°ú ġȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Remove all child nodes from the set of matched elements.
¸ÅÄ¡µÇ¾îÁø ¸ðµç °ÍµéÀ» ¾ø¾Ø´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Removes all matched elements from the DOM.
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¸¦ ¿Å±â´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Clone matched DOM Elements, and all their event handlers, and select the clones.
¿Ïº®ÇÑ º¹»ç
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
1. css( name ) Returns: String
css( name ) ½ÇÇàÈÄ ¹®ÀÚ¿ ¹Ýȯ
Return a style property on the first matched element.
¸ÅÄ¡µÈ ¿ø¼Ò¿¡¼ ÁÖ¾îÁø ½ºÅ¸ÀÏ ¼Ó¼ºÀÌ ¹ß°ßµÇ¸é ±× °ªÀ» ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div").click(function () {
var color = $(this).css("background-color");
$("#result").html("That div is <span style='color:" +
color + ";'>" + color + "</span>.");
});
Set a key/value object as style properties to all matched elements.
¸ÅÄ¡µÇ¾îÁø ¸ðµç ¿ø¼Ò¿¡ ÁÖ¾îÁø Å°¿Í °ªÀ¸·Î ÀÌ·ç¾îÁø ¼Ó¼ºµéÀÇ ¹è¿ÀÇ ½ºÅ¸ÀÏÀ» Àû¿ëÇÏ°í °´Ã¼¸¦ ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
});
</script>
<style>
p { color:green; }
</style>
</head>
<body>
<p>
Move the mouse over a paragraph.
</p>
<p>
Like this one or the one above.
</p>
</body>
</html>
3. css( name, value ) Returns: jQuery
css( name, value ) ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Set a single style property to a value on all matched elements.
ÇϳªÀÇ ¼Ó¼º°ú °ªÀ» ¹Þ¾Æ ¸ÅÄ¡µÇ¾îÁø ¸ðµç ¿ø¼Ò¿¡ Àû¿ë
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
});
</script>
<style>
p { color:blue; width:200px; font-size:14px; }
</style>
</head>
<body>
<p>
Just roll the mouse over me.
</p>
<p>
Or me to see a color change.
</p>
</body>
</html>
Get the current computed, pixel, height of the first matched element.
¸ÅÄ¡µÈ ù¹ø° ¿ø¼ÒÀÇ ³ôÀ̸¦ Çȼ¿·Î ¹ÝȯÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function showHeight(ele, h) {
$("div").text("The height for the " + ele +
" is " + h + "px.");
}
$("#getp").click(function () {
showHeight("paragraph", $("p").height());
});
$("#getd").click(function () {
showHeight("document", $(document).height());
});
$("#getw").click(function () {
showHeight("window", $(window).height());
});
});
</script>
<style>
body { background:yellow; }
button { font-size:12px; margin:2px; }
p { width:150px; border:1px red solid; }
div { color:red; font-weight:bold; }
</style>
</head>
<body>
<button id="getp">Get Paragraph Height</button>
<button id="getd">Get Document Height</button>
<button id="getw">Get Window Height</button>
<div> </div>
<p>
Sample paragraph to test height
</p>
</body>
</html>
6. height( val ) Returns: jQuery
height( val ) ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Set the CSS height of every matched element.
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ÁÖ¾îÁø ³ôÀ̸¦ Àû¿ëÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div").one('click', function () {
$(this).height(30)
.css({cursor:"auto", backgroundColor:"green"});
});
Get the current computed, pixel, width of the first matched element.
¸ÅÄ¡µÇ´Â ù¹ø° ¿ø¼ÒÀÇ ³Êºñ¸¦ Çȼ¿·Î ¹Ýȯ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function showWidth(ele, w) {
$("div").text("The width for the " + ele +
" is " + w + "px.");
}
$("#getp").click(function () {
showWidth("paragraph", $("p").width());
});
$("#getd").click(function () {
showWidth("document", $(document).width());
});
$("#getw").click(function () {
showWidth("window", $(window).width());
});
});
</script>
<style>
body { background:yellow; }
button { font-size:12px; margin:2px; }
p { width:150px; border:1px red solid; }
div { color:red; font-weight:bold; }
</style>
</head>
<body>
<button id="getp">Get Paragraph Width</button>
<button id="getd">Get Document Width</button>
<button id="getw">Get Window Width</button>
<div> </div>
<p>
Sample paragraph to test width
</p>
</body>
</html>
8. width( val ) Returns: jQuery
width( val ) ½ÇÇàÈÄ jQuery °´Ã¼¸¦ ¹Ýȯ
Set the CSS width of every matched element.
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ÁÖ¾îÁø ³Êºñ¸¦ Àû¿ëÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div").one('click', function () {
$(this).width(30)
.css({cursor:"auto", "background-color":"blue"});
});
Binds a function to be executed whenever the DOM is ready to be traversed and manipulated.
¹®¼°¡ Áغñ°¡ µÇ¸é ±× ½ÃÁ¡¿¡ ÇÔ¼ö¸¦ ½ÇÇà½ÃŲ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").text("The DOM is now loaded and can be manipulated.");
});
</script>
<style>p { color:red; }</style>
</head>
<body>
<p>
</p>
</body>
</html>
Binds a handler to a particular event (like click) for each matched element.
ÁöÁ¤µÈ À̺¥Æ®°¡ ÀϾ¶§±îÁö ±â´Ù·Ç´Ù°¡ ÇÔ¼ö ½ÇÇà
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Binds a handler to a particular event to be executed once for each matched element.
ÁöÁ¤µÈ À̺¥Æ®°¡ ÀϾ¶§±îÁö ±â´Ù·Ç´Ù°¡ Çѹø¸¸ ½ÇÇà
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var n = 0;
$("div").one("click", function(){
var index = $("div").index(this);
$(this).css({ borderStyle:"inset",
cursor:"auto" });
$("p").text("Div at index #" + index + " clicked." +
" That's " + ++n + " total clicks.");
});
});
</script>
<style>
div { width:60px; height:60px; margin:5px; float:left;
background:green; border:10px outset;
cursor:pointer; }
p { color:red; margin:0; clear:left; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p>Click a green square...</p>
</body>
</html>
4. trigger( type, data ) Returns: jQuery
trigger( type, data ) ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
Trigger a type of event on every matched element.
¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ÁöÁ¤µÈ ŸÀÔÀÇ À̺¥Æ®¸¦ ¹ß»ý½ÃŲ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
5. triggerHandler( type, data ) Returns: jQuery
triggerHandler( type, data ) ½ÇÇàÈÄ jQuery°´Ã¼ ¹Ýȯ
This particular method triggers all bound event handlers on an element (for a specific event type) WITHOUT executing the browsers default actions.
ÀßÀº ¸ð¸£°ÙÁö¸¸ ½ÇÁ¦ÀûÀÎ ÇàÀ§´Â ÇÏÁö ¾Ê°í ±×°á°ú¸¸ ½ÇÇàÇÑ´Ù´Â ¶æÀÎ°Í °°À½
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
6. unbind( type, data ) Returns: jQuery
unbind( type, data ), ½ÇÇàÈÄ jQuery °´Ã¼ ¹Ýȯ
This does the opposite of bind, it removes bound events from each of the matched elements.
bind¿Í Á¤¹Ý´ëÀÇ ¿ªÈ°À» ÇÏ¸ç ¸ÅÄ¡µÇ´Â ¸ðµç ¿ø¼Ò¿¡ ¹Ù¿îµå À̺¥Æ®¸¦ Á¦°ÅÇÑ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
function aClick() {
$("div").show().fadeOut("slow");
}
$("#bind").click(function () {
// could use .bind('click', aClick) instead but for variety...
$("#theone").click(aClick)
.text("Can Click!");
});
$("#unbind").click(function () {
$("#theone").unbind('click', aClick)
.text("Does nothing...");
});
7. hover( over, out ) Returns: jQuery
hover( over, out ) ½ÇÇàÈÄ jQuery °´Ã¼¸¦ ¹Ýȯ
Simulates hovering (moving the mouse on, and off, an object). This is a custom method which provides an 'in' to a frequent task.
¸¶¿ì½º ¿À¹ö¿Í ¾Æ¿ô½Ã ÇàÀ§¸¦ ÁöÁ¤ÇÒ¼ö ÀÖ´Ù.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("li").hover(
function () {
$(this).append($("<span> ***</span>"));
},
function () {
$(this).find("span:last").remove();
}
);
Toggle between two function calls every other click.
Ŭ¸¯½Ã µÎ°³ÀÇ ÇÔ¼ö¸¦ ¹Ýº¹ÀûÀ¸·Î ½ÇÇà
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("li").toggle(
function () {
$(this).css("list-style-type", "disc")
.css("color", "blue");
},
function () {
$(this).css({"list-style-type":"", "color":""});
}
);
});
</script>
<style>
ul { margin:10px; list-style:inside circle; font-weight:bold; }
li { cursor:pointer; }
</style>
</head>
<body>
<ul>
<li>Go to the store</li>
<li>Pick up dinner</li>
<li>Debug crash</li>
<li>Take a jog</li>
</ul>
</body>
</html>
Binds a function to the change event of each matched element.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
Binds a function to the click event of each matched element.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
2. show( speed, callback ) Returns: jQuery
Show all matched elements using a graceful animation and firing an optional callback after completion.
##A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
3. hide( ) Returns: jQuery
Hides each of the set of matched elements if they are shown.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
</head>
<body>
<p>Hello</p>
<a href="#">Click to hide me too</a>
<p>Here is another paragraph</p>
</body>
</html>
4. hide( speed, callback ) Returns: jQuery
Hide all matched elements using a graceful animation and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
5. toggle( ) Returns: jQuery
Toggles each of the set of matched elements.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
6. slideDown( speed, callback ) Returns: jQuery
Reveal all matched elements by adjusting their height and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
7. slideUp( speed, callback ) Returns: jQuery
Hide all matched elements by adjusting their height and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
8. slideToggle( speed, callback ) Returns: jQuery
Toggle the visibility of all matched elements by adjusting their height and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
});
</script>
<style>
p { width:400px; }
</style>
</head>
<body>
<button>Toggle</button>
<p>
This is the paragraph to end all paragraphs. You
should feel <em>lucky</em> to have seen such a paragraph in
your life. Congratulations!
</p>
</body>
</html>
9. fadeIn( speed, callback ) Returns: jQuery
Fade in all matched elements by adjusting their opacity and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
10. fadeOut( speed, callback ) Returns: jQuery
Fade out all matched elements by adjusting their opacity and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
});
</script>
<style>
p { font-size:150%; cursor:pointer; }
</style>
</head>
<body>
<p>
If you click on this paragraph
you'll see it just fade away.
</p>
</body>
</html>
11. fadeTo( speed, opacity, callback ) Returns: jQuery
Fade the opacity of all matched elements to a specified opacity and firing an optional callback after completion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
</head>
<body>
<p>
Click this paragraph to see it fade.
</p>
<p>
Compare to this one that won't fade.
</p>
</body>
</html>
12. animate( params, duration, easing, callback ) Returns: jQuery
A function for making your own, custom animations.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
13. animate( params, options ) Returns: jQuery
A function for making your own, custom animations.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
// Using multiple unit types within one animation.
$("#go").click(function(){
$("#block").animate({
width: "70%",
opacity: 0.4,
marginLeft: "0.6in",
fontSize: "3em",
borderWidth: "10px"
}, 1500 );
});
14. stop( ) Returns: jQuery
Stops all the currently running animations on all the specified elements.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
15. queue( ) Returns: Array<Function>
Returns a reference to the first element's queue (which is an array of functions).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("#show").click(function () {
var n = $("div").queue("fx");
$("span").text("Queue length is: " + n.length);
});
function runIt() {
$("div").show("slow");
$("div").animate({left:'+=200'},2000);
$("div").slideToggle(1000);
$("div").slideToggle("fast");
$("div").animate({left:'-=200'},1500);
$("div").hide("slow");
$("div").show(1200);
$("div").slideUp("normal", runIt);
}
runIt();
16. queue( callback )
Adds a new function, to be executed, onto the end of the queue of all matched elements.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
17. queue( queue )
Replaces the queue of all matched element with this new queue (the array of functions).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
18. dequeue( ) Returns: jQuery
Removes a queued function from the front of the queue and executes it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){