이번에 사이트를 개편하면서, 탭 메뉴로 구성된 추천 글 목록을 추가했습니다. 제 사이트의 방문자 통계를 확인하니, 방문자들의 이동 경로가 1개의 글만 읽고 사이트를 떠나거나, 홈페이지로 이동하는 등 무척 기초적인 수준의 이용만 하고 있다는 것을 확인했기 때문입니다. 블로그의 글이 360개임에도 불구하고 1~2개 글만 보고 떠나는 걸 방치할 수 없었기에 추가한 콘텐츠입니다. 웹 사이트에서 탭 메뉴를 구현하기 위한 일반적인 방법은 Javascript의 onClick 이벤트를 이용하여, style의 display 속성을 조정하는 것입니다. 이때 보통은 HTML a 태그에 Javascript를 직접 사용하는 방식을 이용합니다. 때문에 이 방법은 구조적인 HTML 마크업과 거리가 멀이질 수 밖에 없죠. 즉, 웹 표준에 어긋난는 방법입니다. 또한 마우스를 사용하지 못하기 때문에 onClick 이벤트를 발생시킬 수 없는 시각장애인의 경우 해당 컨텐츠에 접근하기도 어렵습니다. 제 사이트는 Javascript library로 JQuery를 사용하고 있습니다. JQuery는 파이어폭스나 워드프레스와 비슷한 점이 많습니다 . 예전에 몇몇 글에서 밝혔듯이, 무척 작고 효율적이며, 다양한 기능 외에도 플러그인이 많은 라이브러리죠. 특히 JQuery의 $(document).ready는 DOM의 고질적인 문제인 브라우저의 늦은 랜더링을 해결할 수 있답니다. 탭 메뉴에 해당하는 콘텐츠 구성 저는 사이트 방문객이 좀 더 머무르면서 다양한 콘텐츠에 접근할 수 있는 기회를 제공하기 위해서, 탭 메뉴로 구성된 콘텐츠를 제공하고 싶었습니다. ((-------IMAGE-------)) HTML로 콘텐츠 구조화 탭 메뉴를 책의 목차(Table Of Contents) 형식으로 구성했습니다. 현재의 HTML과 XHTML 스펙에서 가장 구조적인 방법이죠. 물론 앞으로 HTML 5가 채택되어 nav 요소를 사용할 수 있기 전까지 입니다.

CSS로 콘텐츠 시각화 CSS를 이용하여 콘텐츠를 시각적으로 표현했습니다. float 속성을 사용하여 탭 메뉴를 가로로 배치한 점 외에는 특별히 고급 기술을 사용하지 않았습니다. IE가 비순차적 목록(ol)의 상단 마진를 다르게 출력하는 버그 때문에, 2줄의 CSS가 추가됐습니다.

body {
margin:0; padding:0;
font: .75em/1.5 "AppleGothic", "Malgun Gothic", dotum, sans-serif;
}
a { color:#369; font-weight:bold;}
#readMore02 {
position:absolute; top:50%; left:50%;
width:350px;
margin:-120px 0 0 -180px;
border:1px solid #ccc;
}
#readMore02 h2,
#readMore02 h3 { display:none; }
#readMore02 ul {
margin:0; padding:5px 0 0 2px;
height:26px;
border-bottom:1px solid #ccc;
background:#eee;
}
#readMore02 ul li {
list-style:none;
float:left;
margin:0 0 0 3px; padding:0;
position:relative; top:1px;
}
#readMore02 ul li a {
display:block;
padding:.25em .75em;
border:1px solid #ccc;
line-height:1.5; text-decoration:none;
background:#aaa; color:#fff;
}
#readMore02 ul li a:hover,
#readMore02 ul li a:focus,
#readMore02 ul li.tabs-selected a {
border-bottom:1px solid #fff;
background:#fff; color:#f60;
}
#readMore02 div {clear:left;padding-top:1em;} /* IE6 마진 버그 */
#readMore02 div.tabs-selected { display:block; }
#readMore02 div.tabs-hide { display:none; }
#readMore02 ol { margin-top:0; } /* IE6 마진 버그 */
#readMore02 ol li { line-height:2; } JQuery로 콘텐츠 동적 구현 JQuery와 tabs 플러그인을 이용하여 탭 메뉴를 동적으로 구현했습니다. 플러그인에서 지원하는 페이드 효과를 이용하니 훨씬 보기 좋은 탭 메뉴가 구현됐습니다.이 글이 저처럼 블로그에 많은 글을 작성했음에도 불구하고, 예전에 작성한 글이 방문객에게 좀처럼 노출되지 않는 문제로 고민하던 분들에게 도움이 됐으면 좋겠습니다.
by Anna 안나 2008. 11. 16. 20:07
예제 : http://odyniec.net/projects/imgareaselect/examples.php
by Anna 안나 2008. 11. 15. 17:21
<jQuery Core> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266EE?> 1. jQuery( html ) Returns: jQuery
jQuery( html ), 실행후 jQuery객체를 반환 Create DOM elements on-the-fly from the provided String of raw HTML.
주어진 html을 가지고 빠르게 문서 원소를 생성한다.
그리고 jQuery객체로서 그 것을 반환한다.
이말은 그것을 이어서 jQuery의 다른 함수와 함께 사용가능하다는 뜻이다. <!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><p>Hello</p></div>").appendTo("body");
});
</script> </head>
<body>
</body>
</html>
2. jQuery( elements ) Returns: jQuery
jQuery( 원소 ) jQuery( 원소.원소.원소 ), 실행후 jQuery객체를 반환 Wrap jQuery functionality around a single or multiple DOM Element(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(){
$(document.body).css( "background", "black" );
});
</script> </head>
<body>
</body>
</html>
3. jQuery( callback ) Returns: jQuery
jQuery( 콜백함수 ), 실행후 jQuery객체를 반환 A shorthand for $(document).ready().
$()은 $(document).ready() 의 짧은 표현으로 사용가능하다.
$(document).ready() 은 문서가 사용가능한 시점을 자동으로 인식하여 주어진 콜백 함수를 동작시킨다.
콜백함수란 지정된 행위가 끝난다음 자동적으로 실행될 함수를 의미한다. <!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(){ $(document.body).css( "background", "black" );
});
</script> </head>
<body>
</body>
</html>
4. each( callback ) Returns: jQuery
each( 콜백함수 ), 실행후 jQuery객체를 반환 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(){ $(document.body).click(function () {
$("div").each(function (i) {
if (this.style.color != "blue") {
this.style.color = "blue";
} else {
this.style.color = "";
}
});
}); });
</script>
<style>
div { color:red; text-align:center; cursor:pointer;
font-weight:bolder; width:300px; }
</style>
</head>
<body>
<div>Click here</div>
<div>to iterate through</div>
<div>these divs.</div>
</body>
</html>
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 });
</script>
<style>
body { cursor:pointer; }
div { width:50px; height:30px; margin:5px; float:left;
background:blue; }
span { color:red; }
</style>
</head>
<body>
<span></span>
<div></div>
</body>
</html>
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 });
</script>
<style>
body { cursor:pointer; }
div { width:50px; height:30px; margin:5px; float:left;
background:green; }
span { color:red; }
</style>
</head>
<body>
<span></span>
<div></div>
</body>
</html>
7. get( ) Returns: Array<Element>
get( ), 실행후 원소 배열 반환 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(" "));
} disp( $("div").get().reverse() ); });
</script>
<style>
span { color:red; }
</style>
</head>
<body>
Reversed - <span></span>
<div>One</div>
<div>Two</div>
<div>Three</div>
</body>
</html>
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>
9. index( subject ) Returns: Number
index( 객체 ), 실행후 숫자를 반환 Searches every matched element for the object and returns the index of the element, if found, starting with zero.
매치되어진 원소들에 대해 주어진 객체와 동일한것을 검색하여,
존재하면 그 원소들중에 몇번째에 해당하는가 하는 인덱스 번호를 반환한다.
인덱스는 0부터 시작한다. <!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);
}); });
</script>
<style>
div { background:yellow; margin:5px; }
span { color:red; }
</style>
</head>
<body>
<span>Click a div!</span>
<div>First div</div>
<div>Second div</div>
<div>Third div</div>
</body>
</html>
10. jQuery.fn.extend( object ) Returns: jQuery
jQuery.fn.extend( 객체), 실행후 jQuery객체를 반환 Extends the jQuery element set to provide new methods (used to make a typical jQuery plugin).
제이쿼리에 새로운 함수를 확장한다.(플러그인으로 만들어 사용한다.)
<!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>
jQuery.fn.extend({
check: function() {
return this.each(function() { this.checked = true; });
},
uncheck: function() {
return this.each(function() { this.checked = false; });
}
}); $(function(){ $("#button1").click(function(){ $('input').check();
}); $("#button2").click(function(){ $('input').uncheck();
});
});
</script>
<style>
div { background:yellow; margin:5px; }
span { color:red; }
</style>
</head>
<body>
<form>
<input type="checkbox" name="">
<input type="checkbox" name="">
<input type="checkbox" name="">
<input type="checkbox" name="">
<input type="checkbox" name="">
<input type="checkbox" name="">
</form>
<input type='button' id='button1' value='전체선택'>
<input type='button' id='button2' value='전체해제'>
</body>
</html>
11. jQuery.extend( object ) Returns: jQuery
jQuery.fn.extend( 객체), 실행후 jQuery객체를 반환 Extends the jQuery object itself.
제이쿼리 자체를 확장
아직은 잘 모르겟음
14. jQuery.noConflict( ) Returns: jQuery
jQuery.noConflict( ), 실행후 jQuery객체를 반환 Run this function to give control of the $ variable back to whichever library first implemented it.
아직은 잘 모르겠음
15. jQuery.noConflict( extreme ) Returns: jQuery
jQuery.noConflict( extreme ), 실행후 jQuery객체를 반환 Revert control of both the $ and jQuery variables to their original owners. Use with discretion.
아직은 잘 모르겠음



<Selectors>=>객체 선책 닫기" folder_opener="=>객체 선책" use_folder="Y" editor_component="quotation" 2266EE?> 1. #id Returns: Element
#아이디, 실행후 원소 반환 Matches a single element with the given id 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(){
$("#myDiv").css("border","3px solid red");
});
</script>
<style>
div {
width: 90px;
height: 90px;
float:left;
padding: 5px;
margin: 5px;
background-color: #EEEEEE;
}
</style>
</head>
<body>
<div id="notMe"><p>id="notMe"</p></div>
<div id="myDiv">id="myDiv"</div>
</body>
</html>
2. element Returns: Array<Element>
원소명, 실행후 원소 배열 반환 Matches all elements with the given name.
주어진 원소명에 매치되는 모든 원소를 배열로 반환 <!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").css("border","3px solid red");
});
</script>
<style>
div,span {
width: 60px;
height: 60px;
float:left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
}
</style>
</head>
<body>
<div>DIV1</div>
<div>DIV2</div>
<span>SPAN</span>
</body>
</html>
3. .class Returns: Array<Element>
클래스명, 실행후 원소배열로 반환 Matches all elements with 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(){
$(".myClass").css("border","3px solid red");
});
</script>
<style>
div,span {
width: 150px;
height: 60px;
float:left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
}
</style>
</head>
<body>
<div class="notMe">div class="notMe"</div>
<div class="myClass">div class="myClass"</div>
<span class="myClass">span class="myClass"</span>
</body>
</html>
4. * Returns: Array<Element>
모든것, 실행후 원소 배열로 반환 Matches all 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(){
$("*").css("border","3px solid red");
});
</script>
<style>
div,span,p {
width: 150px;
height: 60px;
float:left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
}
</style>
</head>
<body>
<div>DIV</div>
<span>SPAN</span>
<p>P <button>Button</button></p>
</body>
</html>
5. selector1, selector2, selectorN Returns: Array<Element>
selector1, selector2, selectorN, 실행후 원소배열로 반환 Matches the combined results of all the specified selectors.
주어진 것들에 대해 매치되는 모든 원소를 배열로 반환
구분자는 , <!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,span,p.myClass").css("border","3px solid red");
});
</script>
<style>
div,span,p {
width: 130px;
height: 60px;
float:left;
padding: 3px;
margin: 2px;
background-color: #EEEEEE;
font-size:14px;
}
</style>
</head>
<body>
<div>div</div>
<p class="myClass">p class="myClass"</p>
<p class="notMyClass">p class="notMyClass"</p>
<span>span</span>
</body>
</html>
6. ancestor descendant Returns: Array<Element>
조상 자손, 실행후 원소 배열로 반환 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>
7. parent > child Returns: Array<Element>
조상 > 자손, 실행후 원소 배열 반환 Matches all child elements specified by "child" of elements specified by "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(){
$("#main > *").css("border", "3px double red");
});
</script>
<style>
body { font-size:14px; }
span#main { display:block; background:yellow; height:110px; }
button { display:block; float:left; margin:2px;
font-size:14px; }
div { width:90px; height:90px; margin:5px; float:left;
background:#bbf; font-weight:bold; }
div.mini { width:30px; height:30px; background:green; }
</style>
</head>
<body>
<span id="main">
<div></div>
<button>Child</button>
<div class="mini"></div>
<div>
<div class="mini"></div>
<div class="mini"></div>
</div>
<div><button>Grand</button></div>
<div><span>A Span <em>in</em> child</span></div>
<span>A Span in main</span>
</span>
</body>
</html>
8. prev + next Returns: Array<Element>
앞 뒤, 실행후 원소배열 반환 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> </head>
<body>
<form>
<label>Name:</label>
<input name="name" />
<fieldset>
<label>Newsletter:</label>
<input name="newsletter" />
</fieldset>
</form>
<input name="none" />
</body>
</html>
9. prev ~ siblings Returns: Array<Element>
앞원소~형제 원소, 실행후 원소배열 반환 Matches all sibling elements after the "prev" element that match the filtering "siblings" 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(){
$("#prev ~ div").css("border", "3px groove blue");
});
</script>
<style>
div,span {
display:block;
width:80px;
height:80px;
margin:5px;
background:#bbffaa;
float:left;
font-size:14px;
}
div#small {
width:60px;
height:25px;
font-size:12px;
background:#fab;
}
</style>
</head>
<body>
<div>div (doesn't match since before #prev)</div>
<div id="prev">div#prev</div>
<div>div sibling</div>
<div>div sibling <div id="small">div neice</div></div>
<span>span sibling (not div)</span>
<div>div sibling</div>
</body>
</html>
10. :first Returns: Element
첫번째, 실행후 원소 반환 Matches the first selected 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(){
$("tr:first").css("font-style", "italic");
});
</script>
<style>
td { color:blue; font-weight:bold; }
</style>
</head>
<body>
<table>
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
</table>
</body>
</html>
11. :last Returns: Element
마지막, 실행후 원소 반환 Matches the last selected 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(){
$("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'});
});
</script> </head>
<body>
<table>
<tr><td>First Row</td></tr>
<tr><td>Middle Row</td></tr>
<tr><td>Last Row</td></tr>
</table>
</body>
</html>
12. :not(selector) Returns: Array<Element>
아니다, 실행후 원소 배열 반환 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(){ $("input:not(:checked) + span").css("background-color", "yellow");
$("input").attr("disabled", "disabled"); });
</script> </head>
<body>
<div>
<input type="checkbox" name="a" />
<span>Mary</span>
</div>
<div>
<input type="checkbox" name="b" />
<span>Paul</span>
</div>
<div>
<input type="checkbox" name="c" checked="checked" />
<span>Peter</span>
</div>
</body>
</html>
13. :even Returns: Array<Element>
짝수, 실행후 원소 배열 반환 Matches even elements, zero-indexed.
매치된 원소들 중에서 인덱스가 짝수인것 모두 반환한다. <!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>
14. :odd Returns: Array<Element>
홀수, 실행후 원소 배열 반환 Matches odd elements, zero-indexed.
매치된 원소들 중에서 인덱스가 홀수인것 모두 반환한다. <!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> </head>
<body>
<table border="1">
<tr><td>TD #0</td><td>TD #1</td><td>TD #2</td></tr>
<tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>
<tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>
</table>
</body>
</html>
16. :gt(index) Returns: Array<Element>
초과, 실행후 원소 배열 반환 Matches all elements with an index above the given one.
매치된 원소들 중에서 인덱스로 주어진 것보다 큰 인덱스 들을 모두 배열로 반환 <!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:gt(4)").css("text-decoration", "line-through");
});
</script> </head>
<body>
<table border="1">
<tr><td>TD #0</td><td>TD #1</td><td>TD #2</td></tr>
<tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>
<tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>
</table>
</body>
</html>
17. :lt(index) Returns: Array<Element>
미만, 실행후 원소 배열 반환 Matches all elements with an index below the given one.
매치된 원소들 중에서 인덱스로 주어진 것보다 작은 인덱스 들을 모두 배열로 반환 <!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:lt(4)").css("color", "red");
});
</script> </head>
<body>
<table border="1">
<tr><td>TD #0</td><td>TD #1</td><td>TD #2</td></tr>
<tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>
<tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>
</table>
</body>
</html>
18. :header Returns: Array<Element>
헤더, 실행후 원소 배열 반환 Matches all elements that are headers, like h1, h2, h3 and so on.
매치되는 원소들 중에서 h1, h2 ... 와 같은 헤더 태그들을 모두 배열로 반환한다. <!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(){
$(":header").css({ color:'blue' });
});
</script>
<style>
body { font-size: 10px; font-family: Arial; }
h1, h2 { margin: 3px 0; }
</style>
</head>
<body>
<h1>Header 1</h1>
<p>Contents 1</p>
<h2>Header 2</h2>
<p>Contents 2</p>
</body>
</html>
19. :animated Returns: Array<Element>
움직인다, 실행후 원소 배열 반환 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(); });
</script>
<style>
div { background:yellow; border:1px solid #AAA; width:80px; height:80px; margin:5px; float:left; }
div.colored { background:green; }
</style>
</head>
<body>
<button id="run">Run</button>
<div></div>
<div id="mover"></div>
<div></div>
</body>
</html>
20. :contains(text) Returns: Array<Element>
포함, 실행후 원소 배열 반환 Matches elements which contain the given 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(){
$("div:contains('John')").css("text-decoration", "underline");
});
</script> </head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn
</body>
</html>
21. :empty Returns: Array<Element>
비엇다. 실행후 원소 배열 반환 Matches all elements that are empty, be it elements or 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(){
$("td:empty").text("Was empty!").css('background', 'rgb(255,220,200)');
});
</script>
<style>
td { text-align:center; }
</style>
</head>
<body>
<table border="1">
<tr><td>TD #0</td><td></td></tr>
<tr><td>TD #2</td><td></td></tr>
<tr><td></td><td>TD#5</td></tr>
</table>
</body>
</html>
22. :has(selector) Returns: Array<Element>
has(selector), 실행후 원소 배열 반환 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>
23. :parent Returns: Array<Element>
부모, 실행후 원소 배열 반환 Matches all elements that are parents - they have child elements, including 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(){
$("td:parent").fadeTo(1500, 0.3);
});
</script>
<style>
td { width:40px; background:green; }
</style>
</head>
<body>
<table border="1">
<tr><td>Value 1</td><td></td></tr>
<tr><td>Value 2</td><td></td></tr>
</table>
</body>
</html>
24. :hidden Returns: Array<Element>
안보임, 실행후 원소 배열 반환 Matches all elements that are hidden, or input elements of type "hidden".
보이지 않는 모든 것들을 반환한다. none hidden 등, 추가로 input을 지정하면 인풋타입이 히든인것만 받아온다 <!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."); });
</script>
<style>
div { width:70px; height:40px; background:#ee77ff; margin:5px; float:left; }
span { display:block; clear:left; color:red; }
.starthidden { display:none; }
</style>
</head>
<body>
<span></span>
<div></div>
<div style="display:none;">Hider!</div>
<div></div>
<div class="starthidden">Hider!</div>
<div></div>
<form>
<input type="hidden" />
<input type="hidden" />
<input type="hidden" />
</form>
<span>
</span>
</body>
</html>
25. :visible Returns: Array<Element>
보임, 실행후 원소 배열 반환 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(){ $("div:visible").click(function () {
$(this).css("background", "yellow");
});
$("button").click(function () {
$("div:hidden").show("fast");
}); });
</script>
<style>
div { width:50px; height:40px; margin:5px; border:3px outset green; float:left; }
.starthidden { display:none; }
</style>
</head>
<body>
<button>Show hidden to see they don't change</button>
<div></div>
<div class="starthidden"></div>
<div></div>
<div></div>
<div style="display:none;"></div>
</body>
</html>
26. [attribute] Returns: Array<Element>
속성, 실행후 원소 배열 반환 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(){ $("div[id]").one("click", function(){
var idString = $(this).text() + " = " + $(this).attr("id");
$(this).text(idString);
}); });
</script> </head>
<body>
<div>no id</div>
<div id="hey">with id</div>
<div id="there">has an id</div>
<div>nope</div>
</body>
</html>
27. [attribute=value] Returns: Array<Element>
속성=값, 실행후 원소 배열 반환 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> </head>
<body>
<div>
<input type="radio" name="newsletter" value="Hot Fuzz" />
<span>name?</span>
</div>
<div>
<input type="radio" name="newsletter" value="Cold Fusion" />
<span>name?</span>
</div>
<div>
<input type="radio" name="accept" value="Evil Plans" />
<span>name?</span>
</div>
</body>
</html>
28. [attribute!=value] Returns: Array<Element>
속성!=값, 실행후 원소 배열 반환 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> </head>
<body>
<div>
<input type="radio" name="newsletter" value="Hot Fuzz" />
<span>name?</span>
</div>
<div>
<input type="radio" name="newsletter" value="Cold Fusion" />
<span>name?</span>
</div>
<div>
<input type="radio" name="accept" value="Evil Plans" />
<span>name?</span>
</div>
</body>
</html>
29. [attribute^=value] Returns: Array<Element>
속성^=값, 실행후 원소 배열 반환 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> </head>
<body>
<input name="newsletter" />
<input name="milkman" />
<input name="newsboy" />
</body>
</html>
30. [attribute$=value] Returns: Array<Element>
속성$=값, 실행후 원소 배열 반환 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> </head>
<body>
<input name="newsletter" />
<input name="milkman" />
<input name="jobletter" />
</body>
</html>
31. [attribute*=value] Returns: Array<Element>
속성*=값, 실행후 원소 배열 반환 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> </head>
<body>
<input name="man-news" />
<input name="milkman" />
<input name="letterman2" />
<input name="newmilk" />
</body>
</html>
32. [selector1][selector2][selectorN] Returns: Array<Element>
속성들, 실행후 원소 배열 반환 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[id][name$='man']").val("only this one");
});
</script> </head>
<body>
<input id="man-news" name="man-news" />
<input name="milkman" />
<input id="letterman" name="new-letterman" />
<input name="newmilk" />
</body>
</html>
33. :nth-child(index/even/odd/equation) Returns: Array<Element>
몇번째 자식, 실행후 원소 배열 반환 Matches the nth-child of its parent or all its even or odd children.
인덱스나 키워드로 자식을 지정하여 매치되는 것은 모두 반환한다. <!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(){
$("ul li:nth-child(2)").append("<span> - 2nd!</span>");
});
</script>
<style>
div { float:left; }
span { color:blue; }
</style>
</head>
<body>
<div><ul>
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul></div>
<div><ul>
<li>Sam</li>
</ul></div>
<div><ul>
<li>Glen</li>
<li>Tane</li>
<li>Ralph</li>
<li>David</li>
</ul></div>
</body>
</html>
34. :first-child Returns: Array<Element>
첫번째 자식, 실행후 원소 배열 반환 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(){ $("div span:first-child")
.css("text-decoration", "underline")
.hover(function () {
$(this).addClass("sogreen");
}, function () {
$(this).removeClass("sogreen");
}); });
</script>
<style>
span { color:#008; }
span.sogreen { color:green; font-weight: bolder; }
</style>
</head>
<body>
<div>
<span>John,</span>
<span>Karl,</span>
<span>Brandon</span>
</div>
<div>
<span>Glen,</span>
<span>Tane,</span>
<span>Ralph</span>
</div>
</body>
</html>
35. :last-child Returns: Array<Element>
마지막 자식, 실행후 원소 배열 반환 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(){ $("div span:last-child")
.css({color:"red", fontSize:"80%"})
.hover(function () {
$(this).addClass("solast");
}, function () {
$(this).removeClass("solast");
}); });
</script>
<style>
span.solast { text-decoration:line-through; }
</style>
</head>
<body>
<div>
<span>John,</span>
<span>Karl,</span>
<span>Brandon,</span>
<span>Sam</span>
</div>
<div>
<span>Glen,</span>
<span>Tane,</span>
<span>Ralph,</span>
<span>David</span>
</div>
</body>
</html>
36. :only-child Returns: Array<Element>
하나의 자식, 실행후 원소 배열 반환 Matches the only 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(){
$("div button:only-child").text("Alone").css("border", "2px blue solid");
});
</script>
<style>
div { width:100px; height:80px; margin:5px; float:left; background:#b9e }
</style>
</head>
<body>
<div>
<button>Sibling!</button>
<button>Sibling!</button>
</div>
<div>
<button>Sibling!</button>
</div>
<div>
None
</div>
<div>
<button>Sibling!</button>
<button>Sibling!</button>
<button>Sibling!</button>
</div>
<div>
<button>Sibling!</button>
</div>
</body>
</html>
37. :input Returns: Array<Element>
인풋, 실행후 원소 배열 반환 Matches all input, textarea, select and button 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 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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
38. :text Returns: Array<Element>
텍스트, 실행후 원소 배열 반환 Matches all input elements of type 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(){ 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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
39. :password Returns: Array<Element>
패스워드, 실행후 원소 배열 반환 Matches all input elements of type password.
인풋타입이 패스워드인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
40. :radio Returns: Array<Element>
레디오, 실행후 원소 배열 반환 Matches all input elements of type radio.
인풋타입이 레디오인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" name="asdf" />
<input type="radio" name="asdf" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
41. :checkbox Returns: Array<Element>
체크박스, 실행후 원소 배열 반환 Matches all input elements of type checkbox.
인풋타입이 체크박스인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
42. :submit Returns: Array<Element>
서브밋, 실행후 원소 배열 반환 Matches all input elements of type 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 = $(":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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
43. :image Returns: Array<Element>
이미지, 실행후 원소 배열 반환 Matches all input elements of type image.
인풋타입이 이미지인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
44. :reset Returns: Array<Element>
리셋, 실행후 원소 배열 반환 Matches all input elements of type reset.
인풋타입이 리셋인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
45. :button Returns: Array<Element>
버튼, 실행후 원소 배열 반환 Matches all input elements of type button.
인풋타입이 버튼인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
46. :file Returns: Array<Element>
파일, 실행후 원소 배열 반환 Matches all input elements of type file.
인풋타입이 파일인 것을 모두 반환한다. <!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 });
</script>
<style>
textarea { height:45px; }
</style>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
</body>
</html>
47. :hidden Returns: Array<Element>
히든, 실행후 원소 배열 반환 Matches all elements that are hidden, or input elements of type "hidden".
인풋타입이 히든인 것을 모두 반환한다. <!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."); });
</script>
<style>
div { width:70px; height:40px; background:#ee77ff; margin:5px; float:left; }
span { display:block; clear:left; color:red; }
.starthidden { display:none; }
</style>
</head>
<body>
<span></span>
<div></div>
<div style="display:none;">Hider!</div>
<div></div>
<div class="starthidden">Hider!</div>
<div></div>
<form>
<input type="hidden" />
<input type="hidden" />
<input type="hidden" />
</form>
<span>
</span>
</body>
</html>
48. :enabled Returns: Array<Element>
활성화? 사용가능?, 실행후 원소 배열 반환 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> </head>
<body>
<form>
<input name="email" disabled="disabled" />
<input name="id" />
</form>
</body>
</html>
49. :disabled Returns: Array<Element>
비활성화? 사용불가능?, 실행후 원소 배열 반환 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> </head>
<body>
<form>
<input name="email" disabled="disabled" />
<input name="id" />
</form>
</body>
</html>
50. :checked Returns: Array<Element>
체크?음, 실행후 원소 배열 반환 Matches all elements that are checked.
인풋이 체크된 모든 것들을 반환한다. <!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); });
</script>
<style>
div { color:red; }
</style>
</head>
<body>
<form>
<input type="checkbox" name="newsletter" checked="checked" value="Hourly" />
<input type="checkbox" name="newsletter" value="Daily" />
<input type="checkbox" name="newsletter" value="Weekly" />
<input type="checkbox" name="newsletter" checked="checked" value="Monthly" />
<input type="checkbox" name="newsletter" value="Yearly" />
</form>
<div></div>
</body>
</html>
51. :selected Returns: Array<Element>
선택되어짐, 실행후 원소 배열 반환 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(){ $("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
$("div").text(str);
})
.trigger('change'); });
</script>
<style>
div { color:red; }
</style>
</head>
<body>
<select name="garden" multiple="multiple">
<option>Flowers</option>
<option selected="selected">Shrubs</option>
<option>Trees</option>
<option selected="selected">Bushes</option>
<option>Grass</option>
<option>Dirt</option>
</select>
<div></div>
</body>
</html>
<Attributes> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266EE?> 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>
2. attr( properties ) Returns: jQuery
attr(속성배열) 실행후 jQuery객체를 반환 Set a key/value object as 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(){ $("img").attr({
src: "/images/hat.gif",
title: "jQuery",
alt: "jQuery Logo"
});
$("div").text($("img").attr("alt")); });
</script>
<style>
img { padding:10px; }
div { color:red; font-size:24px; }
</style>
</head>
<body>
<img />
<img />
<img />
<div></div>
</body>
</html>
3. attr( key, value ) Returns: jQuery
attr( 속성, 값 ) 실행후 jQuery객체를 반환 Set a single 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(){
$("button:gt(0)").attr("disabled","disabled");
});
</script>
<style>
button { margin:10px; }
</style>
</head>
<body>
<button>0th Button</button>
<button>1st Button</button>
<button>2nd Button</button>
</body>
</html>
4. attr( key, fn ) Returns: jQuery
attr(속성, 콜백함수) 실행후 jQuery 객체를 반환 Set a single property to a computed 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(){ $("img").attr("src", function() {
return "/images/" + this.title;
}); });
</script> </head>
<body>
<img title="hat.gif"/>
<img title="hat-old.gif"/>
<img title="hat2-old.gif"/>
</body>
</html>
5. removeAttr( name ) Returns: jQuery
속성 제거 실행후 jQuery 객체를 반환 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(){ $("button").click(function () {
$(this).next().removeAttr("disabled")
.focus()
.val("editable now");
}); });
</script> </head>
<body>
<button>Enable</button>
<input type="text" disabled="disabled" value="can't edit this" />
</body>
</html>
6. addClass( class ) Returns: jQuery
클래스 추가 실행후 jQuery 객체 반환 Adds the specified class(es) to 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(){
$("p:last").addClass("selected");
});
</script>
<style>
p { margin: 8px; font-size:16px; }
.selected { color:red; }
.highlight { background:yellow; }
</style>
</head>
<body>
<p>Hello</p>
<p>and</p>
<p>Goodbye</p>
</body>
</html>
7. removeClass( class ) Returns: jQuery
클래스 제거 실행후 JQuery 객체를 리턴 Removes all or the specified class(es) 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(){
$("p:even").removeClass("blue");
});
</script>
<style>
p { margin: 4px; font-size:16px; font-weight:bolder; }
.blue { color:blue; }
.under { text-decoration:underline; }
.highlight { background:yellow; }
</style>
</head>
<body>
<p class="blue under">Hello</p>
<p class="blue under highlight">and</p>
<p class="blue under">then</p>
<p class="blue under">Goodbye</p>
</body>
</html>
8. toggleClass( class ) Returns: jQuery
클래스 추가 삭제 반복 실행후 jQuery 객체 리턴 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(){ $("p").click(function () {
$(this).toggleClass("highlight");
}); });
</script>
<style>
p { margin: 4px; font-size:16px; font-weight:bolder;
cursor:pointer; }
.blue { color:blue; }
.highlight { background:yellow; }
</style>
</head>
<body>
<p class="blue">Click to toggle</p>
<p class="blue highlight">highlight</p>
<p class="blue">on these</p>
<p class="blue">paragraphs</p>
</body>
</html>
9. html( ) Returns: String
실행후 문자열을 반환 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을 넣는다. <!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").html("<span class='red'>Hello <b>Again</b></span>");
});
</script>
<style>
.red { color:red; }
</style>
</head>
<body>
<span>Hello</span>
<div></div>
<div></div>
<div></div>
</body>
</html>
11. text( ) Returns: String
실행후 문자열 반환 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>
13. val( ) Returns: String, Array
실행후 문자열이나 배열로 반환 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(", "));
} $("select").change(displayVals);
displayVals(); });
</script>
<style>
p { color:red; margin:4px; }
b { color:blue; }
</style>
</head>
<body>
<p></p>
<select id="single">
<option>Single</option>
<option>Single2</option>
</select>
<select id="multiple" multiple="multiple">
<option selected="selected">Multiple</option>
<option>Multiple2</option>
<option selected="selected">Multiple3</option>
</select>
</body>
</html>
14. val( val ) Returns: jQuery
jQuery 객체를 반환 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);
}); });
</script>
<style>
button { margin:4px; cursor:pointer; }
input { margin:4px; color:blue; }
</style>
</head>
<body>
<div>
<button>Feed</button>
<button>the</button>
<button>Input</button>
</div>
<input type="text" value="click a button" />
</body>
</html>
15. val( val )
반환 없음 Checks, or selects, all the radio buttons, checkboxes, and select options that match the set of values.
체크 박스, 셀렉트 박스 레디오 버튼 셀렉트 옵션 등에 값을 적용
레디오나 체크박스 같은 경우는 값을 여러개 지정하여 할수 있다.
멀티플 같은 경우 배열로서 값을 지정할수 있다. <!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(){ $("#single").val("Single2");
$("#multiple").val(["Multiple2", "Multiple3"]);
$("input").val(["check2", "radio1"]); });
</script>
<style>
body { color:blue; }
</style>
</head>
<body>
<select id="single">
<option>Single</option>
<option>Single2</option>
</select>
<select id="multiple" multiple="multiple">
<option selected="selected">Multiple</option>
<option>Multiple2</option>
<option selected="selected">Multiple3</option>
</select><br/>
<input type="checkbox" value="check1"/> check1
<input type="checkbox" value="check2"/> check2
<input type="radio" name="r" value="radio1"/> radio1
<input type="radio" name="r" value="radio2"/> radio2
</body>
</html>
<Traversing> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266EE?> 1. eq( index ) Returns: jQuery
eq(인덱스) 실행후 jQuery 객체 반환 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(){ $("div").eq(2).addClass("red"); });
</script>
<style>
div { width:60px; height:60px; margin:10px; float:left;
border:2px solid blue; }
.red { background:red; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
2. hasClass( class ) Returns: Boolean
클래스가 있나 없나 실행후 참거짓 리턴 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(){ $("div").click(function(){
if ( $(this).hasClass("protected") )
$(this).animate({ left: -10 }, 75)
.animate({ left: 10 }, 75)
.animate({ left: -10 }, 75)
.animate({ left: 10 }, 75)
.animate({ left: 0 }, 75);
}); });
</script>
<style>
div { width: 80px; height: 80px; background: #abc;
position: relative; border: 2px solid black;
margin: 20px 0px; float: left; left:0 }
div.protected { border-color: red; }
span { display:block; float:left; width:20px;
height:20px; }
</style>
</head>
<body>
<span></span><div class="protected"></div>
<span></span><div></div>
<span></span><div></div>
<span></span><div class="protected"></div>
</body>
</html>
3. filter( expr ) Returns: jQuery
실행후 jQuery 객체를 반환 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(){ $("div").css("background", "#c8ebcc")
.filter(".middle")
.css("border-color", "red"); });
</script>
<style>
div { width:60px; height:60px; margin:5px; float:left;
border:2px white solid;}
</style>
</head>
<body>
<div></div>
<div class="middle"></div>
<div class="middle"></div>
<div class="middle"></div>
<div class="middle"></div>
<div></div>
</body>
</html>
4. filter( fn ) Returns: jQuery
filter(함수) 실행후 jQuery 객체를 반환 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(){ $("div").css("background", "#b4b0da")
.filter(function (index) {
return index == 1 || $(this).attr("id") == "fourth";
})
.css("border", "3px double red"); });
</script>
<style>
div { width:60px; height:60px; margin:5px; float:left;
border:3px white solid; }
</style>
</head>
<body>
<div id="first"></div>
<div id="second"></div>
<div id="third"></div>
<div id="fourth"></div>
<div id="fifth"></div>
<div id="sixth"></div>
</body>
</html>
5. is( expr ) Returns: Boolean
존재 여부 실행후 참거짓 반환 Checks the current selection against an expression and returns true, if at least one element of the selection fits the given 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(){ $("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"});
}); });
</script>
<style>
div { width:60px; height:60px; margin:5px; float:left;
border:4px outset; background:green; text-align:center;
font-weight:bolder; cursor:pointer; }
.blue { background:blue; }
.red { background:red; }
span { color:white; font-size:16px; }
p { color:red; font-weight:bolder; background:yellow;
margin:3px; clear:left; display:none; }
</style>
</head>
<body>
<div></div>
<div class="blue"></div>
<div></div>
<div class="red"></div>
<div><br/><span>Peter</span></div>
<div class="blue"></div>
<p> </p>
</body>
</html>
16. map( callback ) Returns: jQuery
map(콜백함수) 실행후 jQuery 객체 반환 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(){ $("p").append( $("input").map(function(){
return $(this).val();
}).get().join(", ") ); });
</script>
<style>
p { color:red; }
</style>
</head>
<body>
<p><b>Values: </b></p>
<form>
<input type="text" name="name" value="John"/>
<input type="text" name="password" value="password"/>
<input type="text" name="url" value="http://ejohn.org/"/>
</form>
</body>
</html>
17. not( expr ) Returns: jQuery
실행후 jQuery 객체 반환 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(){ $("div").not(".green, #blueone")
.css("border-color", "red"); });
</script>
<style>
div { width:60px; height:60px; margin:10px; float:left;
background:yellow; border:2px solid white; }
.green { background:#8f8; }
.gray {}
#blueone { background:#99f; }
</style>
</head>
<body>
<div></div>
<div id="blueone"></div>
<div></div>
<div class="green"></div>
<div class="green"></div>
<div class="gray"></div>
<div></div>
</body>
</html>
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");

$("span").text('$("div").slice(' + start +
(end ? ', ' + end : '') +
').css("background", "yellow");');
} $("button").click(colorEm); });
</script>
<style>
div { width:40px; height:40px; margin:10px; float:left;
border:2px solid blue; }
span { color:red; font-weight:bold; }
button { margin:5px; }
</style>
</head>
<body>
<button>Turn slice yellow</button>
<span>Click the button!</span>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
19. add( expr ) Returns: jQuery
add( expr ), 실행후 jQuery 객체 반환 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(){

$("div").css("border", "2px solid red")
.add("p")
.css("background", "yellow"); });
</script>
<style>
div { width:60px; height:60px; margin:10px; float:left; }
p { clear:left; font-weight:bold; font-size:16px;
color:blue; margin:0 10px; padding:2px; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p>Added this... (notice no border)</p>
</body>
</html>
20. children( expr ) Returns: jQuery
children( expr ), 실행후 jQuery 객체 반환 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; $("#results span:first").text(len);
$("#results span:last").text(e.target.tagName); e.preventDefault();
return false;
}); });
</script>
<style>
body { font-size:16px; font-weight:bolder; }
div { width:130px; height:82px; margin:10px; float:left;
border:1px solid blue; padding:4px; }
#container { width:auto; height:105px; margin:0; float:none;
border:none; }
.hilite { border-color:red; }
#results { display:block; color:red; }
p { margin:10px; border:1px solid transparent; }
span { color:blue; border:1px solid transparent; }
input { width:100px; }
em { border:1px solid transparent; }
a { border:1px solid transparent; }
b { border:1px solid transparent; }
button { border:1px solid transparent; }
</style>
</head>
<body>
<div id="container">
<div>
<p>This <span>is the <em>way</em> we</span>
write <em>the</em> demo,</p>
</div>
<div>
<a href="#"><b>w</b>rit<b>e</b></a> the <span>demo,</span> <button>write
the</button> demo,
</div>
<div>
This <span>the way we <em>write</em> the <em>demo</em> so</span>
<input type="text" value="early" /> in
</div>
<p>
<span>t</span>he <span>m</span>orning.
<span id="results">Found <span>0</span> children in <span>TAG</span>.</span>
</p>
</div>
</body>
</html>
21. contents( ) Returns: jQuery
contents( ), 실행후 jQuery 객체 반환 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>
22. find( expr ) Returns: jQuery
find( expr ), 실행후 jQuery 객체 반환 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>
23. next( expr ) Returns: jQuery
next( expr ), 실행후 jQuery 객체 반환 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);
}); });
</script>
<style>
span { color:blue; font-weight:bold; }
button { width:100px; }
</style>
</head>
<body>
<div><button>First</button> - <span></span></div>
<div><button>Second</button> - <span></span></div>
<div><button>Third</button> - <span></span></div>
</body>
</html>
24. nextAll( expr ) Returns: jQuery
nextAll( expr ), 실행후 jQuery 객체 반환 Find all sibling elements after the current 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:first").nextAll().addClass("after");
});
</script>
<style>
div { width: 80px; height: 80px; background: #abc;
border: 2px solid black; margin: 10px; float: left; }
div.after { border-color: red; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
25. parent( expr ) Returns: jQuery
parent( expr ), 실행후 jQuery 객체 반환 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(){

$("*", document.body).each(function () {
var parentTag = $(this).parent().get(0).tagName;
$(this).prepend(document.createTextNode(parentTag + " > "));
}); });
</script>
<style>
div,p { margin:10px; }
</style>
</head>
<body>
<div>div,
<span>span, </span>
<b>b </b>
</div>
<p>p,
<span>span,
<em>em </em>
</span>
</p>
<div>div,
<strong>strong,
<span>span, </span>
<em>em,
<b>b, </b>
</em>
</strong>
<b>b </b>
</div>
</body>
</html>
26. parents( expr ) Returns: jQuery
parents( expr ), 실행후 jQuery 객체 반환 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(){

var parentEls = $("b").parents()
.map(function () {
return this.tagName;
})
.get().join(", ");
$("b").append("<strong>" + parentEls + "</strong>"); });
</script>
<style>
b { color:blue; }
strong { color:red; }
</style>
</head>
<body>
<div>
<p>
<span>
<b>My parents are: </b>
</span>
</p>
</div>
</body>
</html>

27. prev( expr ) Returns: jQuery
prev( expr ), 실행후 jQuery 객체 반환 Get a set of elements containing the unique previous 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(){

var $curr = $("#start");
$curr.css("background", "#f99");
$("button").click(function () {
$curr = $curr.prev();
$("div").css("background", "");
$curr.css("background", "#f99");
}); });
</script>
<style>
div { width:40px; height:40px; margin:10px;
float:left; border:2px blue solid;
padding:2px; }
span { font-size:14px; }
p { clear:left; margin:10px; }
</style>
</head>
<body>
<div></div>
<div></div>
<div><span>has child</span></div>
<div></div>
<div></div>
<div></div>
<div id="start"></div>
<div></div>
<p><button>Go to Prev</button></p>
</body>
</html>
28. prevAll( expr ) Returns: jQuery
prevAll( expr ), 실행후 jQuery 객체 반환 Find all sibling elements before the current 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:last").prevAll().addClass("before");
});
</script>
<style>
div { width:70px; height:70px; background:#abc;
border:2px solid black; margin:10px; float:left; }
div.before { border-color: red; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
29. siblings( expr ) Returns: jQuery
siblings( expr ), 실행후 jQuery 객체 반환 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); });
</script>
<style>
ul { float:left; margin:5px; font-size:16px; font-weight:bold; }
p { color:blue; margin:10px 20px; font-size:16px; padding:5px;
font-weight:bolder; }
.hilite { background:yellow; }
</style>
</head>
<body>
<ul>
<li>One</li>
<li>Two</li>
<li class="hilite">Three</li>
<li>Four</li>
</ul>
<ul>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
</ul>
<ul>
<li>Eight</li>
<li class="hilite">Nine</li>
<li>Ten</li>
<li class="hilite">Eleven</li>
</ul>
<p>Unique siblings: <b></b></p>
</body>
</html>
30. andSelf( ) Returns: jQuery
andSelf( ), 실행후 jQuery 객체 반환 Add the previous selection to the current selection.
매치되어진 원소들의 상위의 형제 원소들과 조상 원소 모두를 찾아 추가하여 객체로 반환한다.
이해가 잘 안됨 <!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").find("p").andSelf().addClass("border");
$("div").find("p").addClass("background"); });
</script>
<style>
p, div { margin:5px; padding:5px; }
.border { border: 2px solid red; }
.background { background:yellow; }
</style>
</head>
<body>
<div>
<p>First Paragraph</p>
<p>Second Paragraph</p>
</div>
</body>
</html>
31. end( ) Returns: jQuery
end( ), 실행후 jQuery 객체 반환 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;
}; $("p").showTags(0)
.find("span")
.showTags(1)
.css("background", "yellow")
.end()
.showTags(2)
.css("font-style", "italic"); });
</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>


<Manipulation> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266EE?> 1. html( ) Returns: String
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). 매치되는 모든 원소들에게 주어진 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").html("<span class='red'>Hello <b>Again</b></span>");
});
</script>
<style>
.red { color:red; }
</style>
</head>
<body>
<span>Hello</span>
<div></div>
<div></div>
<div></div>
</body>
</html>
3. text( ) Returns: String
text( ), 실행후 문자열 반환 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>
5. append( content ) Returns: jQuery
append( content ) , 실행후 jQuery 객체 반환 Append content to the inside 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(){
$("p").append("<b>Hello</b>");
});
</script>
<style>p { background:yellow; }</style>
</head>
<body>
<p>I would like to say: </p>
</body>
</html>
6. appendTo( content ) Returns: jQuery
appendTo( content ), 실행후 jQuery 객체 반환 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>
7. prepend( content ) Returns: jQuery
prepend( content ), 실행후 jQuery 객체 반환 Prepend content to the inside 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(){
$("p").prepend("<b>Hello </b>");
});
</script>
<style>p { background:yellow; }</style>
</head>
<body>
<p>there friend!</p>
<p>amigo!</p>
</body>
</html>
8. prependTo( content ) Returns: jQuery
prependTo( content ) 실행후 jQuery 객체 반환 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>
9. after( content ) Returns: jQuery
after( content ), 실행후 jQuery 객체를 반환 Insert content after 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(){
$("p").after("<b>Hello</b>");
});
</script>
<style>p { background:yellow; }</style>
</head>
<body>
<p>I would like to say: </p>
</body>
</html>
10. before( content ) Returns: jQuery
before( content ) 실행후 jQuery 객체를 반환 Insert content before 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(){
$("p").before("<b>Hello</b>");
});
</script>
<style>p { background:yellow; }</style>
</head>
<body>
<p> is what I said...</p>
</body>
</html>
11. insertAfter( content ) Returns: jQuery
insertAfter( content ), 실행후 jQuery 객체 반환 Insert all of the matched elements after 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(){
$("p").insertAfter("#foo"); // check after() examples
});
</script>
<style>#foo { background:yellow; }</style>
</head>
<body>
<p> is what I said... </p><div id="foo">FOO!</div>
</body>
</html>
12. insertBefore( content ) Returns: jQuery
insertBefore( content ), 실행후 jQuery 객체 반환 Insert all of the matched elements before 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(){
$("p").insertBefore("#foo"); // check before() examples
});
</script>
<style>#foo { background:yellow; }</style>
</head>
<body>
<div id="foo">FOO!</div><p>I would like to say: </p>
</body>
</html>
13. wrap( html ) Returns: jQuery
wrap( html ), 실행후 jQuery 객체를 반환 Wrap all matched elements with a structure of other 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(){
$("span").wrap("<div><div><p><em><b></b></em></p></div></div>");
});
</script>
<style>
div { border:2px blue solid; margin:2px; padding:2px; }
p { background:yellow; margin:2px; padding:2px; }
</style>
</head>
<body>
<span>Span Text</span>
<span>Another One</span>
</body>
</html>
14. wrap( elem ) Returns: jQuery
wrap( elem ), 실행후 jQuery 객체 반환 Wrap all matched elements with a structure of other 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").wrap(document.getElementById('content'));
});
</script>
<style>#content { background:#9f9; }</style>
</head>
<body>
<p>Test Paragraph.</p><div id="content"></div>
</body>
</html>
15. wrapAll( html ) Returns: jQuery
wrapAll( html ) 실행후 jQuery 객체 반환 Wrap all the elements in the matched set into a single wrapper element.
매치되는 원소들을 주어진 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(){
$("span").wrapAll("<div><div><p><em><b></b></em></p></div></div>");
});
</script>
<style>
div { border:2px blue solid; margin:2px; padding:2px; }
p { background:yellow; margin:2px; padding:2px; }
strong { color:red; }
</style>
</head>
<body>
<span>Span Text</span>
<strong>What about me?</strong>
<span>Another One</span>
</body>
</html>
16. wrapAll( elem ) Returns: jQuery
wrapAll( elem ), 실행후 jQuery 객체 반환 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>
18. wrapInner( elem ) Returns: jQuery
wrapInner( elem ), 실행후 jQuery 객체를 반환 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>
19. replaceWith( content ) Returns: jQuery
replaceWith( content ), 실행후 jQuery 객체 반환 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(){

$("button").click(function () {
$(this).replaceWith("<div>" + $(this).text() + "</div>");
}); });
</script>
<style>
button { display:block; margin:3px; color:red; width:200px; }
div { color:red; border:2px solid blue; width:200px;
margin:3px; text-align:center; }
</style>
</head>
<body>
<button>First</button>
<button>Second</button>
<button>Third</button>
</body>
</html>
20. replaceAll( selector ) Returns: jQuery
replaceAll( selector ), 실행후 jQuery 객체 반환 Replaces the elements matched by the specified selector with 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(){
$("<b>Paragraph. </b>").replaceAll("p"); // check replaceWith() examples
});
</script>

</head>
<body>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
</body>
</html>
21. empty( ) Returns: jQuery
empty( ) 실행후 jQuery 객체 반환 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(){

$("button").click(function () {
$("p").empty();
}); });
</script>
<style>
p { background:yellow; }
</style>
</head>
<body>
<p>
Hello, <span>Person</span> <a href=";">and person</a>
</p>
<button>Call empty() on above paragraph</button>
</body>
</html>
22. remove( expr ) Returns: jQuery
remove( expr ), 실행후 jQuery 객체를 반환 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(){

$("button").click(function () {
$("p").remove();
}); });
</script>
<style>p { background:yellow; margin:6px 0; }</style>
</head>
<body>
<p>Hello</p>
how are
<p>you?</p>
<button>Call remove() on paragraphs
</body>
</html>
23. clone( ) Returns: jQuery
clone( ) 실행후 jQuery 객체 반환 Clone matched DOM Elements 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(){
$("b").clone().prependTo("p");
});
</script>

</head>
<body>
<b>Hello</b><p>, how are you?</p>
</body>
</html>
24. clone( true ) Returns: jQuery
clone( true ) 실행후 jQuery 객체 반환 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(){

$("button").click(function(){
$(this).clone(true).insertAfter(this);
}); });
</script>

</head>
<body>
<button>Clone Me!</button>
</body>
</html>


<CSS> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266EE?> 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>.");
}); });
</script>
<style>
div { width:60px; height:60px; margin:5px; float:left; }
</style>
</head>
<body>
<span id="result"> </span>
<div style="background-color:blue;"></div>
<div style="background-color:rgb(15,99,30);"></div>
<div style="background-color:#123456;"></div>
<div style="background-color:#f11;"></div>
</body>
</html>
2. css( properties ) Returns: jQuery
css( properties ) 실행후 jQuery 객체 반환 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(){

$("p").hover(function () {
$(this).css({ "background-color":"yellow", "font-weight":"bolder" });
}, function () {
var cssObj = {
"background-color": "#ddd",
"font-weight": "",
color: "rgb(0,40,244)"
}
$(this).css(cssObj);
}); });
</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(){

$("p").mouseover(function () {
$(this).css("color","red");
}); });
</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>
4. offset( ) Returns: Object{top,left}
offset( ) 실행후 탑과 레프트에 해당하는 위치 정보를 반환 Get the current offset of the first matched element relative to the viewport. <!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 p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );
});
</script>
<style>
p { margin-left:10px; }
</style>
</head>
<body>
<p>Hello</p><p>2nd Paragraph</p>
</body>
</html>
5. height( ) Returns: Integer
height( ) 실행후 정수형을 반환한다. 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"});
}); });
</script>
<style>
div { width:50px; height:70px; float:left; margin:5px;
background:rgb(255,140,0); cursor:pointer; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
7. width( ) Returns: Integer
width( ) 실행후 정수형을 반환 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"});
}); });
</script>
<style>
div { width:70px; height:50px; float:left; margin:5px;
background:red; cursor:pointer; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>


<Events> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266ee?> 1. ready( fn ) Returns: jQuery
ready( fn ) 실행후 jQuery 객체를 반환 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>
2. bind( type, data, fn ) Returns: jQuery
bind( type, data, fn ) 실행후 jQuery 객체를 반환 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(){

$("p").bind("click", function(e){
var str = "( " + e.pageX + ", " + e.pageY + " )";
$("span").text("Click happened! " + str);
});
$("p").bind("dblclick", function(){
$("span").text("Double-click happened in " + this.tagName);
}); });
</script>
<style>
p { background:yellow; font-weight:bold; cursor:pointer;
padding:5px; }
span { color:red; }
</style>
</head>
<body>
<p>Click or double click here.</p>
<span></span>
</body>
</html>
3. one( type, data, fn ) Returns: jQuery
one( type, data, fn ) 실행후 jQuery 객체 반환 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(){

$("button:first").click(function () {
update($("span:first"));
});
$("button:last").click(function () {
$("button:first").trigger('click'); update($("span:last"));
}); function update(j) {
var n = parseInt(j.text(), 0);
j.text(n + 1);
} });
</script>
<style>
button { margin:10px; }
div { color:blue; font-weight:bold; }
span { color:red; }
</style>
</head>
<body>
<button>Button #1</button>
<button>Button #2</button>
<div><span>0</span> button #1 clicks.</div>
<div><span>0</span> button #2 clicks.</div>
</body>
</html>
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(){

$("#old").click(function(){
$("input").trigger("focus");
});
$("#new").click(function(){
$("input").triggerHandler("focus");
});
$("input").focus(function(){
$("<span>Focused!</span>").appendTo("body").fadeOut(1000);
}); });
</script>

</head>
<body>
<button id="old">.trigger("focus")</button>
<button id="new">.triggerHandler("focus")</button><br/><br/>
<input type="text" value="To Be Focused"/>
</body>
</html>

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...");
}); });
</script>
<style>
button { margin:5px; }
button#theone { color:red; background:yellow; }
</style>
</head>
<body>
<button id="theone">Does nothing...</button>
<button id="bind">Bind Click</button>
<button id="unbind">Unbind Click</button>
<div style="display:none;">Click!</div>
</body>
</html>
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();
}
); });
</script>
<style>
ul { margin-left:20px; color:blue; }
li { cursor:default; }
span { color:red; }
</style>
</head>
<body>
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Chips</li>
<li>Socks</li>
</ul>
</body>
8. toggle( fn, fn ) Returns: jQuery
toggle( fn, fn ) 실행후 jQuery 객체 반환 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>
9. blur( ) Returns: jQuery
blur( ) 실행후 jQuery 객체 반환 Triggers the blur event of each matched element.
10. blur( fn ) Returns: jQuery
blur( fn ) 실행후 jQuery 객체 반환 Bind a function to the blur event of each matched element.

11. change( ) Returns: jQuery
change( ) 실행후 jQuery 객체 반환 Triggers the change event of each matched element.
12. change( fn ) Returns: jQuery
change( fn ) 실행후 jQuery 객체 반환 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(){

$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " ";
});
$("div").text(str);
})
.change(); });
</script>
<style>
div { color:red; }
</style>
</head>
<body>
<select name="sweets" multiple="multiple">
<option>Chocolate</option>
<option selected="selected">Candy</option>
<option>Taffy</option>
<option selected="selected">Carmel</option>
<option>Fudge</option>
<option>Cookie</option>
</select>
<div></div>
</body>
</html>
13. click( ) Returns: jQuery
click( ) 실행후 jQuery 객체 반환 Triggers the click event of each matched element.
14. click( fn ) Returns: jQuery
click( fn ) 실행후 jQuery 객체 반환 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(){

$("p").click(function () {
$(this).slideUp();
});
$("p").hover(function () {
$(this).addClass("hilite");
}, function () {
$(this).removeClass("hilite");
}); });
</script>
<style>
p { color:red; margin:5px; cursor:pointer; }
p.hilite { background:yellow; }
</style>
</head>
<body>
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Yet one more Paragraph</p>
</body>
</html>
15. dblclick( ) Returns: jQuery
dblclick( ) 실행후 jQuery 객체를 리턴 Triggers the dblclick event of each matched element.
16. dblclick( fn ) Returns: jQuery
dblclick( fn ) 실행후 jQuery 객체를 리턴 Binds a function to the dblclick event of each matched element.
17. error( ) Returns: jQuery
Triggers the error event of each matched element.
18. error( fn ) Returns: jQuery
Binds a function to the error event of each matched element.

19. focus( ) Returns: jQuery
Triggers the focus event of each matched element. 20. focus( fn ) Returns: jQuery
Binds a function to the focus event of each matched element.

21. keydown( ) Returns: jQuery
Triggers the keydown event of each matched element. 22. keydown( fn ) Returns: jQuery
Bind a function to the keydown event of each matched element.

23. keypress( ) Returns: jQuery
Triggers the keypress event of each matched element. 24. keypress( fn ) Returns: jQuery
Binds a function to the keypress event of each matched element.

25. keyup( ) Returns: jQuery
Triggers the keyup event of each matched element. 26. keyup( fn ) Returns: jQuery
Bind a function to the keyup event of each matched element.
27. load( fn ) Returns: jQuery
Binds a function to the load event of each matched element.

28. mousedown( fn ) Returns: jQuery
Binds a function to the mousedown event of each matched element.
29. mousemove( fn ) Returns: jQuery
Bind a function to the mousemove event of each matched element.
30. mouseout( fn ) Returns: jQuery
Bind a function to the mouseout event of each matched element.
31. mouseover( fn ) Returns: jQuery
Bind a function to the mouseover event of each matched element.
32. mouseup( fn ) Returns: jQuery
Bind a function to the mouseup event of each matched element.
33. resize( fn ) Returns: jQuery
Bind a function to the resize event of each matched element.

34. scroll( fn ) Returns: jQuery
Bind a function to the scroll event of each matched element.

35. select( ) Returns: jQuery
Trigger the select event of each matched element. 36. select( fn ) Returns: jQuery
Bind a function to the select event of each matched element.

37. submit( ) Returns: jQuery
Trigger the submit event of each matched element. 38. submit( fn ) Returns: jQuery
Bind a function to the submit event of each matched element.

39. unload( fn ) Returns: jQuery
Binds a function to the unload event of each matched element.



<Effect> 닫기" folder_opener="" use_folder="Y" editor_component="quotation" 2266EE?> 1. show( ) Returns: jQuery
Displays each of the set of matched elements if they are hidden. <!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").show()
});
</script> </head>
<body>
<p style="display:none">Hello</p>
</body>
</html>
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(){ $("button").click(function () {
$("p").show("slow");
}); });
</script>
<style>
p { background:yellow; }
</style>
</head>
<body>
<button>Show it</button>
<p style="display: none">Hello</p>
</body>
</html>
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(){ $("p").hide();
$("a").click(function () {
$(this).hide();
return false;
}); });
</script> </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(){ $("button").click(function () {
$("p").hide("slow");
}); });
</script>
<style>
p { background:#dad; font-weight:bold; }
</style>
</head>
<body>
<button>Hide 'em</button>
<p>Hiya</p>
<p>Such interesting text, eh?</p>
</body>
</html>
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(){ $("button").click(function () {
$("p").toggle();
}); });
</script> </head>
<body>
<button>Toggle</button>
<p>Hello</p>
<p style="display: none">Good Bye</p>
</body>
</html>
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(){ $(document.body).click(function () {
if ($("div:first").is(":hidden")) {
$("div").slideDown("slow");
} else {
$("div").hide();
}
}); });
</script>
<style>
div { background:#de9a44; margin:3px; width:80px;
height:40px; display:none; float:left; }
</style>
</head>
<body>
Click me!
<div></div>
<div></div>
<div></div>
</body>
</html>
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(){ $(document.body).click(function () {
if ($("div:first").is(":hidden")) {
$("div").show("fast");
} else {
$("div").slideUp();
}
}); });
</script>
<style>
div { background:#3d9a44; margin:3px; width:80px;
height:40px; float:left; }
</style>
</head>
<body>
Click me!
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>


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(){ $("button").click(function () {
$("p").slideToggle("slow");
}); });
</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(){ $(document.body).click(function () {
$("div:hidden:first").fadeIn("slow");
}); });
</script>
<style>
span { color:red; cursor:pointer; }
div { margin:3px; width:80px; display:none;
height:80px; float:left; }
div#one { background:#f00; }
div#two { background:#0f0; }
div#three { background:#00f; }
</style>
</head>
<body>
<span>Click here...</span>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
</body>
</html>

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(){ $("p").click(function () {
$("p").fadeOut("slow");
}); });
</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(){ $("p:first").click(function () {
$(this).fadeTo("slow", 0.33);
}); });
</script> </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(){ $("#right").click(function(){
$(".block").animate({"left": "+=50px"}, "slow");
}); $("#left").click(function(){
$(".block").animate({"left": "-=50px"}, "slow");
}); });
</script>
<style>
div {
position:absolute;
background-color:#abc;
left:50px;
width:90px;
height:90px;
margin:5px;
}
</style>
</head>
<body>
<button id="left">≪</button> <button id="right">≫</button>
<div class="block"></div> </body>
</html>
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 );
}); });
</script>
<style>
div {
background-color:#bca;
width:100px;
border:1px solid green;
}
</style>
</head>
<body>
<button id="go">≫ Run</button>
<div id="block">Hello!</div>
</body>
</html>
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(){ // Start animation
$("#go").click(function(){
$(".block").animate({left: '+=100px'}, 2000);
}); // Stop animation when button is clicked
$("#stop").click(function(){
$(".block").stop();
}); // Start animation in the opposite direction
$("#back").click(function(){
$(".block").animate({left: '-=100px'}, 2000);
}); });
</script>
<style>div {
position: absolute;
background-color: #abc;
left: 0px;
top:30px;
width: 60px;
height: 60px;
margin: 5px;
}
</style>
</head>
<body>
<button id="go">Go</button>
<button id="stop">STOP!</button>
<button id="back">Back</button>
<div class="block"></div>
</body>
</html>
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(); });
</script>
<style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
span { color:red; }
</style>
</head>
<body>
<button id="show">Show Length of Queue</button>
<span></span>
<div></div>
</body>
</html>
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(){ $(document.body).click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},2000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
}); });
</script>
<style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
</style>
</head>
<body>
Click here...
<div></div>
</body>
</html>
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(){ $("#start").click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},5000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},1500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
$("#stop").click(function () {
$("div").queue("fx", []);
$("div").stop();
}); });
</script>
<style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
</style>
</head>
<body>
<button id="start">Start</button>
<button id="stop">Stop</button>
<div></div>
</body>
</html>
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(){ $("button").click(function () {
$("div").animate({left:'+=200px'}, 2000);
$("div").animate({top:'0px'}, 600);
$("div").queue(function () {
$(this).toggleClass("red");
$(this).dequeue();
});
$("div").animate({left:'10px', top:'30px'}, 700);
}); });
</script>
<style>
div { margin:3px; width:50px; position:absolute;
height:50px; left:10px; top:30px;
background-color:yellow; }
div.red { background-color:red; }
</style>
</head>
<body>
<button>Start</button>
<div></div>
</body>
</html>
by Anna 안나 2008. 11. 15. 17:16
jQuery와 프로토타입과 충돌하는 부분이 있기는한데 jQuery에서 간단히 충돌을 피해갈 수 있습니다.
http://docs.jquery.com/Using_jQuery_with_Other_Libraries 여기에서 방법이 자세히 나와있구요.
저는 $j에 할당하여 사용하고 있습니다. 이 페이지에도 적용이 되어 있습니다.

자바스크립트 프레임웍에 대한 실행속도, 로드속도에 관해서 비교자료가 여럿 있는데, 그것보다 중요한게 사용하기 쉽고 빠른개발과 유지보수에 큰 비중을 두고 싶습니다. jQuery가 개발속도를 높이는데 큰 도움이 되리라 보는데, 제가 자주 돌아다니는 사이트들 중에는 jQuery를 사용하는 곳이 phpschool.com 밖에 보이질 않네요^^; 프로토타입이 아직은 많이 사용되고 있는 것 같습니다.

'JS > jquery' 카테고리의 다른 글

renderCalendar  (0) 2008.12.14
플러그인 소개 demo  (0) 2008.12.14
JQuery를 이용한 겸손한 탭 메뉴 구현  (0) 2008.11.16
imgAreaSelect Examples  (0) 2008.11.15
JQuery 기초예제  (0) 2008.11.15
jQuery 트리, 폴더형 위젯 플러그인 5가지  (0) 2008.11.15
Custom JavaScript Dialog Boxes  (0) 2008.11.13
jQuery Feed Menu for Multiple Feeds  (0) 2008.11.13
mcDropdown jQuery Plug-in v1.1a  (0) 2008.11.13
PNG-Transparency for Windows IE 5.5 & 6  (0) 2008.11.13
by Anna 안나 2008. 11. 15. 17:04

BogoFolders

폴더형 구조를 가진 플러그인입니다.
아 름답게(?) 생기지는 못하지만 CSS로 얼마든지 꾸밀 수 있는 부분이죠. 코드압축하지 않은 파일크기는 11Kb 가량이지만, 코드 반 이상을 차지하고 있는 메뉴얼 같은 주석을 제거하면 5Kb 가량으로 줄어들고, 코드압축(minimized)하면 2.5Kb까지 줄어듭니다.

안내 및 다운로드 : http://wanderinghorse.net/computing/javascript/jquery/bogofolders
데모 페이지 : http://wanderinghorse.net/computing/javascript/jquery/bogofolders/demo-bogofolders.html



treeView깔끔한 트리구조의 플러그인입니다.

list 태그(ol.ul등)를 트리구조로 렌더링하므로 특별한 구조를 취한다거나, JSON데이터를 갖출 필요도 없습니다. 쿠키를 이용하여 최종 선택된 항목을 기억하여 페이지 이동시에도 유지합니다.

Ajax 이용도 가능합니다.

트리구조를 표현하는 외의 기능은 없으나, 항목이 많은 구조에서도 비교적 빠르게 랜더링하고, 파일크기도 작습니다.

파일크기는 경량화된 코드기준으로 3.3Kb 가량입니다.



안내 및 다운로드 : http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
메뉴얼 : http://docs.jquery.com/Plugins/Treeview



dynatree

jQuery 플러그인 저장소에 있는 제가 가장 눈독들이고 있는 트리 플러그인입니다.

ul, ol 등 리스트 태그를 트리구조로 랜더링하는 것은 물론, Ajax를 지원하고 다양한 이벤트 콜백을 지원합니다.
무엇보다 키보드로 항목을 선택하고 하위 트리를 펼칠 수 있습니다.

안내 페이지 : http://wwwendt.de/tech/dynatree/index.html
다운로드 : http://code.google.com/p/dynatree/downloads/list
매뉴얼 : http://wwwendt.de/tech/dynatree/doc/dynatree-doc.html
데모 : http://wwwendt.de/tech/dynatree/doc/sample-2.html



CheckTree트리형이지만, 앞에 체크박스를 달고 있습니다.
동영상 코덱팩 등을 설치할 때 보았던 구조입니다.

상/하위 구조를 가지고 수 많은 항목의 선택을 요구하는 페이지에서 유용하게 사용될 수 있으리라 생각됩니다. 상위 항목을 선택하면 하위 항목이 자동적으로 전체 선택됩니다.

경량화 되지 않은 파일크기는 8Kb 가량입니다.




안내 및 매뉴얼 : http://static.geewax.org/checktree/index.html
다운로드 : http://code.google.com/p/jquery-checktree/downloads/list



simpleTreedTree라는 스크립트와 아이콘이 동일해서 jQuery플러그인으로 컨버팅한건가 싶었지만, 다른것 같네요.

Ajax를 지원하지만, 마크업에 의존성이 있습니다.

트리항목을 이동할 수 있기에 카테고리 등의 구조를 작성하는 페이지에 사용하기에 유용할 듯 합니다.

경량화하지 않은 파일크기는 14Kb 정도입니다.


안내, 다운로드 : http://news.kg/wp-content/uploads/tree/
by Anna 안나 2008. 11. 15. 15:56
Custom JavaScript Dialog Boxes는 우리가 흔히 만나는 Javascript 경고창(로그인시 비밀번호를 입력해 달라는등의 경고창)을 예쁘게 커스터마이징해서 보여주는 Javascript 라이브러리다. 4.5kb 정도의 아주 작은 용량으로 CSS 파일과 몇개의 이미지, 그리고 라이브러리 파일인 JS 파일이 있다. 간단하게는 단순 경고문 박스로도 이용 할 수 있지만 Wordpress나 Zeroboard XE같은 Generator 파일을 직접 손봐서 경고창 자체를 시스템내에 직접 적용하는 편이 훨씬 활용도가 높다. 따라서 디자이너보다는 개발자측에서 더 유용하게 사용 될 수 있다. 총 4개의 Theme Set로 구성되어 있는데, Error 박스, Warining 박스, Success 박스, Prompt 박스로서 Javascript 경고창이 가지는 모든 속성을 커버한다. 각 박스마다 각각의 용도에 맞는 디자인이 짜여져 있다. 이것들은 첨부된 CSS 파일을 직접 만지므로 해서 디자인 자체를 커스터마이징 할 수도 있다. IE 6/7, FireFox 2/3, Opera와 Safari에서도 검증 된 높은 접근성과 웹 표준지향 코드이므로 웹 규격에 맞게 개인 블로그나 사이트를 제작하는 디자이너나 개발자들에게 큰 도움이 된다. From Original I have put together a lightweight (~4.5kb) JavaScript dialog box library. The script currently offers four dialog styles: alerts, warnings, prompts and success. There is nothing to add to your page except references to the JavaScript and CSS if you choose not to incorporate them in your existing files. The Divs are dynamically added to the DOM when the function is called. The function currently relies on a content wrapper to calculate the page height however you could use the body height but the background overlay would only cover the currently visible content. The variable for the wrapper ID as well as the speed and timer settings are available at the top of the JavaScript file.
by Anna 안나 2008. 11. 13. 00:57
When feeds became popular, it worked to have one icon on your site to point your readers to your RSS or Atom feeds. As feeds are more prevalent in blogs and websites abroad, the presence of multiple feeds abound. It’s nice to offer users a way to get your feeds, so typically you will see a feed icon lurking around a site somewhere. At times, you will see a list of two, three or more links to different feeds offered on a site. Why not have an easy and standard way of offering your feeds via a nice, compact menu, just like in the location bar, but on your site? jQuery Feed Menu can do this for you easily. It allows users to click your feed icon and be presented with a list of feeds to choose from.
by Anna 안나 2008. 11. 13. 00:55
Jquery 라이브러리를 이용한 편리한 계층화 셀렉트 메뉴 플러그인인 mcDropdown jQuery Plug-in v1.1a가 Giva Lab에 업데이트 되었다. <li>를 태그를 이용하여 간단하게 메뉴를 계층화 할 수 있으며 마우스오버에 의한 메뉴다운 효과나 Fade, Blind등의 이펙트들을 일일이 설정 할 수 있다.

이 메뉴는 특별히 사이즈를 조절하지 않더라도 플러그인이 위치한 곳에 자동으로 폭을 맞춰준다. 카테고리가 많은 사이트나 블로그에 설치하여 디자인을 커스터마이징 해준다면 최고의 성능을 발휘해 줄 수도 있다. (메뉴의 스크롤바 버튼이라던가 계층 버튼등도 모두 사용자가 직접 이미지를 수정해서 사용 할 수도 있다)

CSS 부분에서는 브라우저 접근성을 위한 Hack 사용에 의해 유효성 검사를 통과하지는 못한다. 이번 업데이트에서는 Safari 브라우저등에서의 몇가지 CSS 버그들을 고쳐 접근성 부부분에 대한 안정성을 한층 강화하였다.
by Anna 안나 2008. 11. 13. 00:55
This plugin will fix the missing PNG-Transparency in Windows Internet Explorer 5.5 & 6.
by Anna 안나 2008. 11. 13. 00:53
jQuery에서 더욱 확장된 Easing 기능을 제공하는 플러그인 사이트 입니다. 이 플러그인을 사용하면 굉장히 다양한 Ease In, Out 기능을 jQuery에서 혼용하여 사용 할 수 있습니다.


// Animate DIV
$(document).ready(function(){
jQuery.easing.def = 'easeOutQuart';

// Using multiple unit types within one animation.

$(".left").click(function(){
$("#left").animate( { width:"400px" }, 1500)
});

$(".middle").click(function(){
$("#middle").animate( { width:"400px"}, 1500 )
});

$(".both").click(function(){
$(".left").add(".middle").click();
});

$(".reset").click(function(){
$("div").css({width:""});
});

});


위와같이 셋팅하는 것이 일단 가장 나은것 같고요. Ease의 종류는 링크 건 사이트에서 풀다운 메뉴에 해당하는 부분의 이름을 써주시면 효과가 바뀝니다




그 사이트에 있는 자바스크립트 코드는, 여러가지 샘플을 풀다운 메뉴를 통해서 한번에 보여주려고 변수처리를 해서 그렇고요, 우리는 그렇게 복잡하게 안써도 됩니다^^
by Anna 안나 2008. 11. 8. 15:33
이번에 제작하게 되는 레이아웃은 Jquery라는 자바스크립트 프레임워크를 사용하게 되는데, 한마디로 웹브라우저를 제어하는 장치라고 생각하시면 됩니다. 이 프레임워크를 쓰려면 일련의 JS 파일들을 레이아웃 폴더에 넣고 등록을 시키게 됩니다. 아래의 두 사이트는 앞으로 가장 많이 찾아 볼 사이트라서 링크를 시켜 놓습니다.

* Jquery 공식 사이트
* Jquery UI 코어 사이트

그리고 이번 제작에서 목표로 하게 되는 기능은 여기 사이트와 가장 흡사한 동작을 하는 것 입니다. 이게 엄청 만만치 않은 작업이라 스터디 중간에 다른 길로 샐 수도 있습니다. 하지만 근본적은 목표는 레이아웃의 횡형 접기 기능입니다.

현재 Forum에 등록해 놓은 테스트 레이아웃 파일은 Animate라는 파라메터로 구현 할 수 있는 부분까지를 적용해 놓은 것 입니다. 여기까지의 일련의 과정을 정리하자면 이렇습니다. (밑에 내용은 이미 다 적용을 해서 test.zip 파일에 적용이 된 상태임)

1. jquery.com에서 jquery-1.2.6.js 파일을 다운 받습니다. Jquery를 레이아웃에서 돌릴 수 있게 해주는 가장 기본적인 파일입니다.


2. 웹상에서 <div>단의 폭을 넓히고 좁히는등의 애니메이션을 사용하기 위해 Jquery에는 없는 추가 라이브러리용 JS를 Jquery UI 코어 사이트에서 다운로드 받습니다. 레이아웃 폴더내의 JS 폴더안에 있는 effects.min.js가 바로 그것입니다. 이 파일이 있어야 애니메이션이 가능해지니다.


3. 레이아웃 폴더의 layout.html에서 최상단에 각 JS 파일들을 레이아웃에 연결시키는 코드를 추가했습니다.

<!-- js 파일 import -->
<!--%import("js/xe_official.js")-->
<!--%import("js/jquery.pack.js")-->
<!--%import("js/effects.min.js")-->
<!--%import("js/global.js")-->


4. global.js는 Jquery 구문을 작동시키기 위한 실질적인 변수와 핸들러들이 정의되어 있습니다. layout.html에 일일이 넣으면 엄청나게 길어지기 때문에 따로 JS 파일로 빼 놓은것이 되겠습니다.
by Anna 안나 2008. 11. 8. 15:32
1.1 Changelog

- new options API
- jQuery.noconflict() compatibility
- Fixed progress bar showing when progress = false
- Added escape key to close modal window
- Tweaked the progress bar fading time
- Added default options
- Added center option to force center position on container
- Overlay color can now be specified in the options
- Overlay opacity can now be specified in the options
- Better destruction for Flash and embedded objects
- Better data structure for multiple instances

Usage Include all the neccessary javascripts <script language="javascript" type="text/javascript" src="jquery-1.2.3.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jdialog.js"></script>

Understanding the API and defining values progress: (true|false) means display a progress bar when AJAX calls are fetching a new page
center: (true|false) mean try to center your content/container relative to your browser window width and height
method: ('GET'|'POST') use get method or post method to submit data
data: serialized data to be passed to page, i.e. date=12/24/08&page=2&content=true (hint: use $.serialize in jQuery library)
opacity: (0-1.0) opacity of the overlay background
bg: any heaxdecimal color ie. #FFFFFF for the overlay background
index: the z-index of the background
addr: loading the ajax content from this url. Must be from same exact domain (note: www.example.com != example.com)

Here are the internally default values progress: false,
center: true,
method: 'GET',
data: '',
opacity: 0.85,
bg: '#FFFFFF',
index: 2000
addr: not defined
Overiding the default values. This step is totally optional $.fn.createDialog.defaults = {
progress: false,
center: true,
method: 'GET',
data: '',
opacity: 0.85,
bg: '#FFFFFF',
index: 2000
};
Creating a dialog $("#clickme").createDialog({
addr: 'dialog.htm',
opacity: 0.9
});
Closing a dialog $.closeDialog()
note: only one dialog can be active. This function will only close current dialog
Putting it all together <script language="javascript" type="text/javascript" src="jquery-1.2.3.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jdialog.js"></script>
<script language="javascript">

$(document).ready(function()
//you can optionally define default options{
$.fn.createDialog.defaults = {
progress: true,
center: true,
opacity: 0.7,
bg: '#FFF'
}

$("#clickme").createDialog({
addr: 'dialog.htm',
opacity: 0.9
}); });

</script>
Demo Download


by Anna 안나 2008. 11. 8. 14:17
categories: front-end development, howto, jquery There are lots of examples of using CSS to add filetype icons to links, but they all rely on advanced CSS selectors, which Internet Explorer 6 doesn't support. If you're looking for a cross-browser method of adding filetype icons to links, you have a couple of choices: you can add a class name to all of your links and target that class name with CSS that IE6 can understand; or you can let Javascript add the links dynamically based on the extension it finds at the end of each URL. The class name method is fine if you don't mind adding the class to all of your links in your HTML, but the Javascript method will figure out which links get which icon automatically. The Javascript/jQuery method This uses my favorite Javascript library, jQuery; you'll need to include the library in your document, and then either put the icon-adding code in another file you include, or put it inline with your HTML. It's good practice to put all your jQuery code inside $.ready(), to be executed when the document is ready to be manipulated, but I've left that part out here for brevity. Round 1: Because jQuery supports CSS1-3, you can mimic the CSS rule that wouldn't work in IE6: $('a[href$=".doc"]'). css({ // use paddingLeft instead of padding-left; // jQuery (and Javascript) use camelCase // for CSS attributes instead of hyphenation paddingLeft: '18px', background: 'transparent url("word-doc.gif") no-repeat center left' }); Round 2: You could do one of these snippets for each file type, but with jQuery, you can take advantage of the $.each() utility method to do a loop, eliminating redundant code: // first, create an object // that contains information // about how file extensions // correspond to images var fileTypes = { // extension: 'image file' doc: 'doc.gif', xls: 'xls.gif', pdf: 'pdf.gif' }; // then, loop over the object // using jQuery's $.each() $.each(fileTypes, function(extension,image) { $('a[href$="' + extension + '"]'). css({ paddingLeft: '18px', background: 'transparent url("' + image + '") no-repeat center left' }); }); Round 3: One problem with this: while jQuery does support these attribute selectors, in my experience they require some pretty heavy lifting to do the pattern matching, which can slow things down significantly. Since the method above would require multiple selections (one for each extension/image combination), it makes sense to try a different way that will require fewer selections and less pattern matching: var fileTypes = { doc: 'doc.gif', xls: 'xls.gif', pdf: 'pdf.gif' }; // this is like $.each() above, except // it iterates over the matched elements $('a').each(function() { // get a jQuery object for each anchor found var $a = $(this); // get the href attribute var href = $a.attr('href'); // get the extension from the href var hrefArray = href.split('.'); var extension = hrefArray[hrefArray.length - 1]; var image = fileTypes[extension]; if (image) { $a.css({ paddingLeft: '18px', background: 'transparent url("' + image + '") no-repeat center left' }); } }); And in fact, in limited testing using Firebug, this second version is faster than the first if you have more than two filetypes (and thus more than two selections). Taking it further You can also add a different icon to external links, and only add filetype icons to internal links: var fileTypes = { doc: 'doc.gif', xls: 'xls.gif', pdf: 'pdf.gif' }; $('a').each(function() { var $a = $(this); var href = $a.attr('href'); if ( (href.match(/^http/)) && (! href.match(document.domain)) ) { // use a special image for external links var image = 'external.gif'; } else { // get the extension from the href var hrefArray = href.split('.'); var extension = hrefArray[hrefArray.length - 1]; var image = fileTypes[extension]; } if (image) { $a.css({ paddingLeft: '18px', background: 'transparent url("' + image + '") no-repeat center left' }); } }); Or, only add icons to certain links, like a list of files in an unordered list, by changing your selector from $('a') to $('ul#fileList a'). Resources There are nuances to the CSS you'll want to apply to your links; the above is just an example of something that may or may not work for you. Read more here about how to style the links so your background images appear as you want them to. If you're using transparent PNGs for your background images, iepngfix will save the day. famfamfam has some great icons available for free under the Creative Commons Attribution 2.5 License. The class name method In case you were wondering ... First, put a class name on the link: <a href="my-word-document.doc" class="word-doc">Word Document</a> ... and then style it using CSS: a.word-doc { padding-left: 18px; background: transparent url('word.gif') no-repeat center left;
by Anna 안나 2008. 11. 8. 02:44
jHelperTip is intended to be useful in many situations such as hovering tip and clickable tips. It can get data from a container, through Ajax or even the attributes of the current object. Download
Demo The API and Default Values$.fn.jHelperTip.defaults = { trigger: "click", topOff: 3, leftOff: 10, source: "container", attrName: '', ttC: "#jHelperTipContainer", /* tooltip Container*/ dC: "#jHelperTipDataContainer", /* data Container */ aC: "#jHelperTipAttrContainer", /* attr Container */ opacity: 1.0, loadingImg: "ajax-loader.gif", loadingText: "Loading...", type: "GET", /* data can be inline or CSS selector */ //url: '', //data: '', autoClose: true };
Explanation of the Options: trigger: “click” or “hover” to trigger the tooltip
topOff: top offset from mouse pointer
leftOff: left offset from mouse pointer
source: can be “container”, “ajax” or “attribute”, container is an container in current page, ajax loads from another page, attribute will read the attribute of current object.
attrName: the attribute that you want to pass the data from (only works if your source is attribute)
ttC: tooltip container (define a container to position your tooltip and receive data from ajax), will create if container not found use “#container” and not “container”
dC: data container for same page container (only works if your source is container)
aC: attribute data container (only works if your source is attribute)
opacity: opacity of the tooltips
loadingImg: the loading image indicator in Ajax calls (only works if your source is ajax)
loadingText: the loading text indicator in Ajax calls (only works if your source is ajax)
type: “GET” or “POST” (only works if your source is ajax)
url: The address of the page that you are fetching from (only works if your source is ajax)
data: data passed to the ajax request (only works if your source is ajax)
autoClose: true or false, specify if explicit action is needed to close the tooltip Special Case jHelperTipClose : clicking on any element that has this class will make the current tooltip close ExamplesjQuery.noConflict(); jQuery(function($){ $("#test").jHelperTip({ trigger: "click", dC:"#tip1", autoClose: false, opacity: 0.9 }); <div>Matt is doing something <span id="test">dangerous</span></div> <div id="tip1" style="display:none"> <div class="jHelperTipClose" style="cursor:pointer;color:#F00">click here to close</div> <p>adj.</p> <p>1. Involving or filled with danger; perilous.</p> <p> 2. Being able or likely to do harm.</p> </div>
Digg for me if you like the story. These icons link to social bookmarking sites where readers can share and discover new web pages. });
</script>

<div id="myController">
<span class="jFlowControl">No 1 </span>
<span class="jFlowControl">No 2 </span>
<span class="jFlowControl">No 3 </span>
<span class="jFlowControl">No 4 </span>
</div>

<div id="mySlides">
<div>First Slide</div>
<div>Second Slide </div>
<div>Third Slide </div>
<div>Fourth Slide </div>
</div>

<span class="jFlowPrev">Prev</span>
<span class="jFlowNext">Next</span> Download
Demo
by Anna 안나 2008. 11. 8. 02:40
Getting tired of the default context menu (the one that appears when you right click on a web page) that are being displayed in all browsers? Now, web developers can focus on designing the menu itself rather than worrying about the javascript code. This tutorial will assume that you have enough CSS knowledge and familiarity using jQuery to begin with. Believe it or not… sub menus are and should be a CSS problem. Here’s a sample of the submenu CSS
DownLoad

How lightweight is jContext? It’s approximately 0.6kB when minified. Usage$(obj).showMenu({ opacity:0.8, query: "#myMenu2", zindex: 2000 }); opacity: can be from 0 - 1.0, opacity of the menu being displayed query: can be any object or CSS selector that jQuery recognizes zindex: z-index of the menu being displayed
Full Example<span>Right Click me</span> <p>You can right Click me too </p> <div id="myMenu"> <ul> <li><a href="#">Edit This Type</a></li> <li><a href="#">Create New Type</a></li> <li><a href="#">Book a Flight</a></li> </ul> </div> <div id="myMenu2"> <ul> <li><a href="#">Create New Class</a></li> <li><a href="#">Delete Class</a></li> <li><a href="#">Get a Job</a></li> </ul> </div> <script language="javascript" type="text/javascript" src="j/jquery-1.2.3.min.js"></script> <script language="javascript" type="text/javascript" src="j/jquery.jcontext.1.0.js"></script> <script language="javascript"> $(document).ready(function(){ $("span").showMenu({ opacity:0.8, query: "#myMenu" }); $("p").showMenu({ opacity:0.8, query: "#myMenu2" }); }); </script>
Demo
Download Now
by Anna 안나 2008. 11. 8. 02:39
Gone were the days of framesets during the late 90s. Usability studies then showed that frames (not iframe) are detremental. The Web 2.0 platform has made the frames concept emerge once again in another form to simulate interfaces that are found in desktop software. As a frequent Yahoo! mail or even Live mail user, you probably have noticed that you can resize reading panels by dragging the sliders/helpers. In this era, we are now talking about divs not frames and making them behave does take quite a bit of effort in your CSS and JavaScripting. I am approaching this problem from a JavaScript perspective, the CSS to make it work is still daunting if you don’t have a firm concept of it. Let’s look at a illustration of what the example layout will be. To make #v-slide and #h-slide work as a slider/resizer, just simply do this.

$("#v-slide").jSize({
type: 'left-right',
c1: '#left',
c2: '#right',
static: '#left'
}); $("#h-slide").jSize({
type: 'top-bottom',
c1: '#top',
c2: '#bottom',
static: '#top'
}); Let us look at the code above and see what it means. type: (left-right | top-bottom) those are the two choices for your slider
c1: (jQuery css selectors) means the left container or the top container
c2: (jQuery css selectors) means the right container or the bottom container
static: (jQuery css selectors) the container that has min-width and max-width specified on their CSS (either c1 or c2). Word of caution: min-width and max-width for your container plays an extremely important role to prevent the frames from breaking. Demo
jqueryjsize10 Download
by Anna 안나 2008. 11. 8. 02:34


Changelog - fixed animation forward flowing and backward timing per tab to be consistent
jFlow is a widget to make your content slides. One popular alternative that exists out there is coda-slider. jFlow is super lightweight because it is only 1.9kb minified!!!.

Demo
Download

Usage
$("#myController").jFlow({
slides: "#mySlides",
width: "99%",
height: "200px",
duration: 400
});

Explanation: #myController: the div where all the slide controller are nested in
slides: the div where all your sliding divs are nested in (note: you can define classes for each div inside slides)
width: can be specified in px or % (required)
height: can be specified in px (required)
duration: time in miliseconds to transition one slide (optional, default is 400) 2 divs created by jFlow as containers, you can style them to your liking #jFlowSlide: This is the container where all the slides reside
.jFlowSelected: This is the current activated controller Special class definition .jFlowPrev: Any element with this class will transition to previous slide upon clicking
.jFlowNext: Any element with this class will transition to next slide upon clicking
.jFlowControl: Any element inside the controlling div with this class will map to the corresponding slide Example

<script language="javascript">
$(document).ready(function(){
$("#myController").jFlow({
slides: "#mySlides",
width: "99%",
height: "200px",
duration: 400
});
});
</script> <div id="myController">
<span class="jFlowControl">No 1 </span>
<span class="jFlowControl">No 2 </span>
<span class="jFlowControl">No 3 </span>
<span class="jFlowControl">No 4 </span>
</div> <div id="mySlides">
<div>First Slide</div>
<div>Second Slide </div>
<div>Third Slide </div>
<div>Fourth Slide </div>
</div> <span class="jFlowPrev">Prev</span>
<span class="jFlowNext">Next</span>
by Anna 안나 2008. 11. 8. 02:29
This plugin will easily allow you to do color transitions for text, background and borders for different events. The API
trigger: the event that will fire color transition, uses the same events as bind in jQuery
property: can be 'background', 'borderColor' or 'color'
start: the starting color ie '336699'
end: the ending color ie '6699CC'
steps: the number of times to divide the color difference
duration: the transition speed
Default values
$.fn.jFade.defaults = {
trigger: "load",
property: 'background',
start: 'FFFFFF',
end: '000000',
steps: 5,
duration: 30
};

Demo
Download
by Anna 안나 2008. 11. 8. 02:06
Click the http://docs.jquery.com/Downloading_jQuery
위 링크를 클릭하세요.

Please download 'Current Release'
'Current Release' 를 다운받으세요.

If you don't develope JQuery, please download 'Minified'
JQuery 를 개발하지 않는다면 'Minified' 를 다운받으세요.
by Anna 안나 2008. 11. 8. 02:03
이전에 유효성이니 접근성이니 꽤 고리타분한 이야기에서 벗어나서 이제 Effects 부분들입니다. 먼저 사이트에 각 기능성 플러그인들을 작동시키기 전에 몇가지 참고할 만한 부분들을 짚고 넘어가겠습니다. 이것은 Planning 1과 2에서 다루지 못했던 부분이거나 따로 파트를 나누기엔 소소한 부분들입니다.

#1 최초 사이트 스킨은 대암지기님의 스킨으로
사이트의 스킨을 만들때는 항상 제로보드 XE 기본 스킨으로 시작하는 것이 좋습니다. 아시는 분은 다 아시겠지만 기존에 변경된 스킨을 사용하면 추가, 삭제된 코드들 때문에 혼동이 올 수 있으니 되도록이면 보드 스킨도 기본 Official 스킨을 사용하시는 것이 좋겠습니다. 그리고 많은 플러그인들이 제로보드의 확장변수와 연동되서 작동하게 되므로 확장변수에 대한 이해도 미리 해놓으시면 좋습니다. 확장변수를 게시판에 쉽게 적용 할 수 있도록 대암지기님께서 등록하신 스킨이 가장 좋습니다. 기본 스킨에 확장변수 부분만 편리하게 정리한 아주 좋은 스킨입니다.

#2 Jquery를 호출 할 자바스크립트는 별도 JS 파일로 관리
Jquery용 플러그인을 호출 할때 쓰이는 자바스크립트 구문들은 모두 스킨 html 파일에 넣지 말고 따로 global.js등으로 분리하여 layouts 폴더의 js 폴더내에 저장하는 것이 좋습니다. 이 부분은 이번 내용에 포함되어 있으니 아래 Fade In MouseOver 부분에서 같이 하시면 되겠습니다.

#3 @font-face를 이용한 웹 폰트 사용
WTA에서는 @font-face를 사용해서 조그마한 도트 폰트를 사용하고 있습니다. 인터넷 익스플로러에서만 작동하는 이 Function은 CSS 2.1에 포함되지 않은 비표준 코드입니다. 하지만 CSS3에서는 표준으로 사용 될 예비 코드입니다. 사용을 해도 앞으로 문제가 없는 부분이므로 용도에 맞게 적용하시면 좋은 효과를 보실 수도 있습니다. 더 많은 CSS3의 기능들을 살펴보시려면 이 드래프트 문서를 참고해서 W3C에 제출된 로드맵을 살펴보세요.

#4 글쓰기 버튼을 이용한 컨텐츠 등록은 FireFox로
게시판에 컨텐츠를 올릴때 HTML 태그 부분에 버그가 있습니다. IE에서는 특정 태그(예를들면 P나 BR태그)들이 한번 저장하고나서 수정화면으로 들어가면 대문자로 바뀌어 있습니다. 대문자로 바뀐 태그는 CSS 유효성 검사에서 에러를 일으킵니다. FireFox에서는 태그가 대문자로 변경되는 일은 없습니다. 다만 IMG 태그 맨 뒤에 슬러쉬(/)가 붙지 않아 이 또한 에러로 처리 됩니다. 유효성 검사에 뜻을 많이 두시는 분은 글 수정 하실때 일일이 본문내의 이미지 태그 뒤에 슬러쉬를 다시 붙인 후 등록을 해야하는 번거로움이 있습니다.


Fade In MouseOver
WTA 겔러리 썸네일에서 마우스가 겔러리의 Thumbnail 이미지 위에 올려졌을때 Fade In, Out하는 효과입니다. 이 효과는 BestWebGallery, CSS Gallery등에서 볼 수 있습니다. 단 몇줄의 Jquery 구문만으로 처리하는 간단한 방법이지만 다른 많은 썸네일 이미지보다 가독성을 끌어올리는 역할을 합니다. 이 스크립트는 CSS Gallery의 Skill Share라는 이용자 포럼에서 질문과 답변 부분을 검색해 찾은 내용입니다.

먼저 global.js라는 빈 파일을 만들고 아래의 구문을 넣어 저장합니다. Jquery 구문은 비단 보드 뿐만아니라 레이아웃이나 기타 스킨에서도 언제든지 쉽게 불러 올 수 있어야 하므로 레이아웃 스킨에 넣는 것을 권장합니다.

/zbxe/layouts/스킨폴더명/js/global.jsFade In MouseOverview plaincopy to clipboardprint?$(document).ready(function(){ $(".thumb").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads $(".thumb").hover(function(){ $(this).fadeTo("slow", 0.2); // This should set the opacity to 100% on hover },function(){ $(this).fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout }); }); $(document).ready(function(){ $(".thumb").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads $(".thumb").hover(function(){ $(this).fadeTo("slow", 0.2); // This should set the opacity to 100% on hover },function(){ $(this).fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout }); });
제로보드 기본스킨의 style.gallery.html에 보면 썸네일 이미지를 둘러싸고 있는 DIV태그는 .thumb입니다. 그래서 위와같이 MouseOver 되었을 때의 효과가 .thumb 클래스에서만 작동되도록 작성된 코드입니다. Jquery가 설치되어 있다면 이 코드만으로 마우스오버는 작동합니다.
by Anna 안나 2008. 11. 2. 00:25

#1. jquery.tooltip의 셋팅
겔러리의 썸네일 이미지에 마우스를 올리면 Preview 이미지가 마우스를 따라다니는 효과는 webtrendawards와 bestwebgallery에서 볼 수 있습니다. 이 기능은 bassistance.de에서 오픈소스로 내놓은 Jquery의 플러그인 Tooltip을 사용합니다. 기본적으로는 마우스오버가 되었을 시에 Text를 출력하지만, 제로보드의 확장변수와 함께 사용해서 약간의 마크업 팁을 응용하면 간단히 Preview 이미지를 넣을 수 있습니다.

먼저 이 툴팁 오픈소스를 제공하는 사이트에서 약간의 데모와 기능을 살펴보고 필요한 파일을 다운로드 합니다. 다운로드 받은 파일의 압축을 풀면 꽤 여러가지 파일들이 나오는데, 여기서는 마우스 오버시에 이미지가 출력되는 부분만 취급할 것이므로 그 외의 기능에 대한 설명은 생략하고 그에 해당하는 파일들의 설치법에서도 거론하지 않겠습니다.

압축을 푼 파일중에서 필요한 파일은 다음과 같습니다.

jquery.tooltip.js jquery.dimensions.js jquery.js이 중에서 jquery.js는 이미 이전에 설명한 바 있고 이미 설치되어 있다는 가정하에, 나머지 두개의 자바스크립트를 계정에 복사하여 설치합니다. 다른 JS 파일의 Include와 마찬가지로 layout.html에 추가하면 됩니다. (jquery.dimensions.js는 미리보기 이미지가 화면의 끝쪽으로 밀려서 안보이게 되는 경우, 공간이 넓은쪽으로 자동으로 밀어주는 역할을 해줍니다)

만일 Jquery대신 Prototype을 사용하는 이용자의 경우에는 Prototip 2라는 툴팁 플러그인이 있습니다. 이 플러그인 사용을 권장합니다. Jquery의 툴팁에는 없는 토글 기능이나 기타 여러가지 부수기능이 더 많이 구현되어 있고 디자인도 깔끔하게 베이스로 깔려있어 사용하기가 좋습니다.

/zbxe/layouts/스킨폴더명/layout.html레이아웃 파일에 JS 파일을 Include 합니다
<!-- js 파일 import -->
<!--%import("js/xe_official.js")-->
<!--%import("js/jquery.js")-->
<!--%import("js/jquery.dimensions.js")-->
<!--%import("js/jquery.tooltip.js")-->
4번 5번 줄이 새로 추가된 툴팁 관련 JS 입니다. 이제 레이아웃에 연동되어 있는 CSS파일 (기본은 default.css)를 열고 아래의 CSS 코드를 추가합니다.
#tooltip.preview {
background: url('../images/default/preview.png') no-repeat;
padding: 27px 15px 17px 18px;
border: none;
position: absolute;
z-index: 3000;
}

Preivew 이미지가 놓일 배경 이미지의 경로를 적어줍니다. 이 이미지 위에 미리보기 이미지가 얹혀지게 되는데, 배경이미지와 미리보기 이미지간의 정렬은 padding 값으로 합니다. 이 padding 값을 적절히 조절하면 배경이미지와 미리보기 이미지의 위치를 원하는 위치에 정확히 가져다 놓을 수 있습니다.

이전에 등록한 링크 사이트 제작을 위한 어드바이스 - Fade In MouseOver -편에서 설명했듯이 이번에는 global.js에 코드를 추가 할 차례입니다.
// Tooltip
$(function() {
$(".preview").tooltip({
track: true,
delay: 0,
showURL: false,
opacity: 1,
fixPNG: true,
showBody: "",
extraClass: "preview",
top: -35,
left: 20
});
});

여기까지 jquery.tooltip의 기능을 이용하기 위한 기본 셋팅은 끝났습니다. 이제 제로보드 XE에서 확장변수 부분을 끌어와서 화면에 출력시키는 부분을 연결하게 됩니다.


#2 제로보드 XE의 셋팅
먼저 제로보드 XE 관리자 페이지에서 게시판 정보수정을 통해 확장변수 한개를 활성화 시킵니다. 이 확장변수는 글쓴이로부터 미리보기 이미지의 경로를 입력받아 화면에 출력시킵니다. 형식은 한줄입력칸(홈페이지 URL 형식도 무관)으로 설정합니다. 이 확장변수는 번호 1번에 지정했으므로 style.gallery.html에서 호출할때도 변수 1로 호출하게 됩니다.

/zbxe/modules/board/skins/보드스킨명/style.gallery.htmljquery.tooltip을 제로보드와 연결합니다
<!-- 갤러리 목록 출력 -->
{@ $height = $module_info->thumbnail_height + 50; }
<!--@if($module_info->use_category=='Y')-->{@ $height += 20 }<!--@end-->
<!--@if($module_info->display_author!='N' || $module_info->display_regdate!='N')-->{@ $height += 25 }<!--@end-->
<!--@if($module_info->display_readed_count !='N' || $module_info->display_voted_count!='N')-->{@ $height += 25 }<!--@end-->

<div class="thumbnailBox">

<!--@foreach($document_list as $no => $document)-->
<!--@if(!$document->isNotice())-->

<div class="cell" style="width:{$module_info->thumbnail_width+30}px;height:{$height}px;">
<!--@if($document->thumbnailExists($module_info->thumbnail_width, $module_info->thumbnail_height, $module_info->thumbnail_type))-->
<a href="{getUrl('document_srl',$document->document_srl,'listStyle',$listStyle, 'cpage','')}"><img src="{$document->getThumbnail($module_info->thumbnail_width, $module_info->thumbnail_height, $module_info->thumbnail_type)}" border="0" alt="" class="thumb"/></a>
<!--@else-->
<img src="./images/common/blank.gif" border="0" alt="" class="thumb" width="{$module_info->thumbnail_width}" height="{$module_info->thumbnail_height}" />
<!--@end-->

위와 같이 style.gallery.html 파일에서 갤러리 목록이 출력되는 부분을 찾아봅니다. 썸네일 이미지 위에 마우스가 올라가면 이전에 지정한 확장변수에 입력된 이미지 경로가 출력되어야 하므로 14번째 a코드 줄을 수정하게 됩니다. 이 툴팁은 preview라는 이름의 클래스가 지정되어야 하고 title 셀렉터의 내용에 기재된 부분을 마우스 오버 팁으로 전환시켜주므로 두 부분을 수정해서 아래의 코드로 변경합니다.
<a
href="{getUrl('document_srl',$document->document_srl,'listStyle',$listStyle,
'cpage','')}" class="preview" title="&lt;img src={htmlspecialchars($document->get('extra_vars1'))} /&gt;"><img
src="{$document->getThumbnail($module_info->thumbnail_width,
$module_info->thumbnail_height, $module_info->thumbnail_type)}"
border="0" alt="" class="thumb"/></a>

이제 위 코드에서 class와 title이 지정된 것이 보입니다. 특히 title 셀렉터 부분을 유심히 봐야하는데, 본래는 여기에 일반 텍스트가 놓여지게 됩니다. 하지만 이미지를 출력시키기 위한 꽁수로 이미지 태그에 들어가는 꺽쇠를 위와같이 코드표시용 코드로 바꿔서 태그 자체를 삽입하면 title 셀렉터에 이미지 태그를 넣을 수 있습니다. 그리고 이미지 태그의 경로는 확장변수 1번이 지정한 경로를 불러오게끔 되어 있습니다.

이렇게해서 여러분은 갤러리 화면에 마우스 오버 미리보기 이미지를 사용 할 수 있게 됩니다.
by Anna 안나 2008. 11. 2. 00:25
| 1 2 |