오늘자 ajaxian에 올라온 포스트 중에 jQuery Tip으로 링크에 걸린 파일사이즈를 자동으로 알아낸뒤 링크뒤에 출력해주는 포스팅을 번역해서 올려본다.



jQuery(function($){
$('a[href$=".pdf"], a[href$=".doc"], a[href$=".mp3"], a[href$=".m4u"]').each(function(){
// looking at the href of the link, if it contains .pdf or .doc or .mp3
var link = $(this);
var bits = this.href.split('.');
var type = bits[bits.length -1];


var url= "http://json-head.appspot.com/?url="+encodeURI($(this).attr('href'))+"&callback=?";

// then call the json thing and insert the size back into the link text
$.getJSON(url, function(json){
if(json.ok && json.headers['Content-Length']) {
var length = parseInt(json.headers['Content-Length'], 10);

// divide the length into its largest unit
var units = [
[1024 * 1024 * 1024, 'GB'],
[1024 * 1024, 'MB'],
[1024, 'KB'],
[1, 'bytes']
];

for(var i = 0; i <units.length; i++){

var unitSize = units[i][0];
var unitText = units[i][1];

if (length>= unitSize) {
length = length / unitSize;
// 1 decimal place
length = Math.ceil(length * 10) / 10;
var lengthUnits = unitText;
break;
}
}

// insert the text directly after the link and add a class to the link
link.after(' (' + type + ' ' + length + ' ' + lengthUnits + ')');
link.addClass(type);
}
});
});
});


소스에서 굵게 표시된 json.headers 를 이용해서 컨텐츠의 사이즈를 알아온뒤 link.after메쏘드로 화면에 출력해 주었다...
너무도 간단하게.. ㅡ.,ㅡ;

addSizes.js

샘플사이트 : http://natbat.net/code/clientside/js/addSizes/
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>addSizes</title>
<!-- Date: 2008-07-29 -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script src="addSizes.js" type="text/javascript"></script>
</head>
<body>
<h1>addSizes</h1>
<p>This is a link to a remote <a href="http://clearleft.com/worksheet/client-worksheet.doc">doc</a> file.</p>
<p>This is a link to a remote <a href="http://www.onyx.com/pdf/CustomerMgmtBrochure.pdf">pdf</a> file.</p>
<p>This is a link to a remote <a href="http://media.giantbomb.com/podcast/giantbombcast-071708.mp3">mp3</a> file.</p>

<p>This is a link to a local <a href="media/test.doc">doc</a> file.</p>
<p>This is a link to a remote <a href="media/test.pdf">pdf</a> file.</p>
<p>This is a link to a remote <a href="media/test.mp3">mp3</a> file.</p>
</body>
</html>

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

jQuery 스크롤 페이징  (0) 2012.01.16
스크롤 페이징(Scroll Paging, Continuous scrolling pattern)  (0) 2012.01.16
How to Mimic the iGoogle Interface  (0) 2009.03.01
The 20 Most Practical and Creative Uses of jQuery  (0) 2009.02.27
jQuery Plugin  (0) 2009.02.23
jQuery Loading바 구현하기  (0) 2009.01.05
Test if jquery has loaded  (0) 2009.01.05
IE를 위해 코딩할때  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
by Anna 안나 2009. 1. 5. 01:23
이미 아는 사람들은 다아는 로딩바 원하는 형태로 만들기 사이트(http://www.ajaxload.info/)에서 좋은 Loading Indicator(Spinner)를 구한 다음에 아래와 같이 간단히 구현할 수 있다.

jQuery(function($){
// Create img dom element and insert it into our document
var loading = $('<img alt="loading" src="/images/loading.gif" />')
.appendTo(document.body).hide();
// Make the image appear during ajax calls
$(window).ajaxStart(loading.show);
$(window).ajaxStop(loading.hide);
});


참고적으로 요기도 보아두면 좋아요~~
jQuery를 모르는 분들은 여기서 부터 시작하세요
by Anna 안나 2009. 1. 5. 01:21
$(document).ready(function() {
alert('hi');
});

This uses jQuery's .ready function on the document object




Sure. You could do this:if (typeof jQuery != 'undefined') { // do something}

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

How to Mimic the iGoogle Interface  (0) 2009.03.01
The 20 Most Practical and Creative Uses of jQuery  (0) 2009.02.27
jQuery Plugin  (0) 2009.02.23
jQuery 링크에 걸린 파일 사이즈 자동으로 알아내기  (0) 2009.01.05
jQuery Loading바 구현하기  (0) 2009.01.05
IE를 위해 코딩할때  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
by Anna 안나 2009. 1. 5. 01:20
var qustn = $('body').layout({
north: { initClosed: false, size: "52", closable: false, resizable: false },
defaults: { applyDefaultStyles: true }
});

아무거나 예제를 들고왔다.
맨끝에 ,(쉼표) 를 붙이면 안된다.
연결을 위해서 중간에 , 를 붙이기도 하지만..
파폭에는 상관없는데, 익스에서는 맨끝에 쉼표를 붙이면 안먹혀진다..ㅠㅠ흑.
(저는 IE7에서 테스트해봤습니다)

이것때매 얼마나고생했는지..참..

파폭에서 잘되길래 되겠지 하며 IE7을 켰더니 참담~하더라!

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

The 20 Most Practical and Creative Uses of jQuery  (0) 2009.02.27
jQuery Plugin  (0) 2009.02.23
jQuery 링크에 걸린 파일 사이즈 자동으로 알아내기  (0) 2009.01.05
jQuery Loading바 구현하기  (0) 2009.01.05
Test if jquery has loaded  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
by Anna 안나 2009. 1. 5. 00:48
http://cssglobe.com/lab/textgradient/

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

jQuery Plugin  (0) 2009.02.23
jQuery 링크에 걸린 파일 사이즈 자동으로 알아내기  (0) 2009.01.05
jQuery Loading바 구현하기  (0) 2009.01.05
Test if jquery has loaded  (0) 2009.01.05
IE를 위해 코딩할때  (0) 2009.01.05
jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
by Anna 안나 2009. 1. 4. 21:56
16+ Top JavaScript/Ajax Effects for Modern Web Design 웹 개발자, 웹 디자이너를 위한 16가지의 자바 스크립트 / Ajax 효과 Aug 06, 2008, by Mohsen as Javascript/AJAX These days, I’m designing a new Wordpress theme for aComment. new logo, new design, more features and a better dress!The coding of the theme is nearly finished and just some minor details should be added. Okay, this post is related to JavaScript and its friends!
Currently there are a lot of JS scripts available for web developers. But all of them are not handy in the modern web design. Nowadays, web designers use some special effects more and more in their projects because those effects give usability and practicality as well as elegance to their projects. In this list, I’ve selected some of the most common in use JavaScript effects for modern web design.


1 - Easiest Tooltip and Image Preview Using jQuery - A clean and easy to use jQuery tooltip & image preview script (마우스 롤 오버 툴팁 및 이미지 미리보기) 2- jQuery idTabs - These days using tabs in Wordpress themes and websites is common. iTabs is a plugins for jQuery that makes adding tabs to a website really simple. (탭 기능 플러그인)
3- Coda-Slider - A jQuery plugins for tabs with sliding animation (슬라이딩 탭?)
4- prettyPhoto a jQuery lightbox clone - A very beautiful lightbox for images with next/previous buttons, caption and preload animation for both single images and galleries. (이미지 갤러리)
5- Glass Box - GlassBox is a compact Javascript User Interface (UI) library, which use Prototype and Script.aculo.us for some effects. With GlassBox you can build transparent border, colorful layouts and “Flash-like” effects. The GlassBox library .. (UI 라이브러리)
6- SimpleModal Dialog Box - it comes with 3 example, basic dialog box, contact form and confirm override. 7- CSS Text Gradient - “Text Gradient is a simple css trick that allows you to improve your site’s appearance by putting gradients on system font titles using nothing but css and a png image.” (텍스트 그레디언트 효과) 8- Simple Javascript Accordions - is a very small JS accordion script which is really handy in today’s web projects. 9- Custom JavaScript Dialog Boxes - “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.” (커스텀 다이얼로그 박스) 10- Dynamic JavaScript Form Validation - It’s clear:) (자바스크립트 동적 폼 검사) 11- jQuery Lightbox Plugin (balupton edition) - another jQuery lightbox plugins with only 15KB size
12- AutoCompleter - This AutoCompleter script for MooTools provides the functionality for text suggestion and completion. It features different data-sources (local, JSON or XML), a variety of user interactions, custom formatting, multiple selection, animations and much more. (폼 자동 완성기능) 13- Top Floating message box using jQuery - This effect will be useful for advertising, hot news, etc 14- Easy AJAX inline text edit 2.0 - an easy to integrate inline text edit script. No JavaScript knowledge needed, just follow the five steps for integration. 15- Create site tours with Amberjack - Amberjack is a lightweight Open Source library, enabling webmasters to create cool site tours. 16- Accordion Menu script - It became really easy to make accordion menu using this script. 17- Create a Slick Tabbed Content Area using CSS & jQuery - Finally, this tutorial from NETTUTS demonstrates how to create a slick tabbed content area for your themes. You see tabbed content boxes in a lot of websites these days specially in Wordpress themes. 자바스크립트와 AJAX를 이용한 다양한 플러그인들. 실제 웹 개발에 유용하게 사용될 수 있는 것들이 모아져 있다. 이런 라이브러리들을 활용해서 좀 더 멋진 웹 사이트를 만들 수 있겠군..
by Anna 안나 2009. 1. 4. 21:33
안녕하세요?
최근 가장 인기있는 자바스크립트 라이브러리는 jQuery입니다.
MS도 ASP.NET MVC에 jQuery를 포함시킬 예정입니다.이미 시중에 jQuery 책이 번역되어 나와 있지만,
IBM 사이트에서 jQuery 강좌를 번역해서 연재하고 있으니까
이것을 먼저 보시는 것도 좋으리라 생각합니다.http://www.ibm.com/developerworks/kr/library/wa-jquery1/index.html
http://www.ibm.com/developerworks/kr/library/wa-jquery2/index.htmlhttp://www.ibm.com/developerworks/kr/library/x-ajaxjquery.html
http://www.ibm.com/developerworks/kr/library/wa-aj-overhaul1/index.html
http://www.ibm.com/developerworks/kr/library/wa-aj-overhaul2/index.html

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

jQuery 링크에 걸린 파일 사이즈 자동으로 알아내기  (0) 2009.01.05
jQuery Loading바 구현하기  (0) 2009.01.05
Test if jquery has loaded  (0) 2009.01.05
IE를 위해 코딩할때  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
가볍고 쉬운 Ajax - jQuery 시작하기  (0) 2008.12.14
by Anna 안나 2008. 12. 14. 19:34
provenance 참조

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

jQuery Loading바 구현하기  (0) 2009.01.05
Test if jquery has loaded  (0) 2009.01.05
IE를 위해 코딩할때  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
가볍고 쉬운 Ajax - jQuery 시작하기  (0) 2008.12.14
renderCalendar  (0) 2008.12.14
by Anna 안나 2008. 12. 14. 19:33
provenance 참조

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

Test if jquery has loaded  (0) 2009.01.05
IE를 위해 코딩할때  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
가볍고 쉬운 Ajax - jQuery 시작하기  (0) 2008.12.14
renderCalendar  (0) 2008.12.14
플러그인 소개 demo  (0) 2008.12.14
by Anna 안나 2008. 12. 14. 19:32
provenance 참조

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

IE를 위해 코딩할때  (0) 2009.01.05
CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
가볍고 쉬운 Ajax - jQuery 시작하기  (0) 2008.12.14
renderCalendar  (0) 2008.12.14
플러그인 소개 demo  (0) 2008.12.14
JQuery를 이용한 겸손한 탭 메뉴 구현  (0) 2008.11.16
by Anna 안나 2008. 12. 14. 19:31
jQuery를 활용한 쇼핑 카트 구현 예제 jQuery를 활용하여 쇼핑 카트를 만들어봤는데 재밌네요.
좀더 확장하면 쇼핑몰에 응용할 수 있는 수준이군요. 예제 링크 1. Draggables 1.1 Options: handle string or DOMElement optional the handel that starts the draggable revert boolean optional when true, on stop drag the element returns to initial position ghosting boolean optional when true a copy of the element is moved zIndex integer optional zIndex depth for the element while in drag opacity float ( < 1) optional opacity for the element while in drag grid mixed (integer or array) optional define a grid for draggable to snap to fx integer optional duration for the effect applied to the draggable containment string ('parent' or 'document') or array (left, top, width, height) optional define the zone where the draggable can be moved. Use value 'parent' to move it inside parent element, 'document' for not moving it outside the document, so no extra scroll. axis string ('vertically' or 'horizontally') optional define the axis which the dragged elements moves on onStart function optional callback function triggered when the dragging starts onStop function optional callback function triggered when the dragging stops onChange function optional callback function triggered when the dragging stops and elements was moved at least one pixel onDrag function optional callback function triggered while the element is dragged. Receives two parameters the x and y coordinates. You can return an object with new coordinates {x: new x, y: new y} so this way you can interact with the dragging process, build your containment for instance. insideParent boolean optional tell whatever the element is dragged inside its parent snapDistance integer optional the dragged element is not moved unless is moved more then snapDistance. This way you can prevent accidental dragging cursorAt object optional the dragged element is moved to the cursor position with the offset specified. Accepts value for top, left, right and bottom offset. autoSize boolean optional when true the drag helper is resized to its content, instead of the dragged element's sizes frameClass String optional When is set the cloned element is hidden so only a frame is dragged 1.2 사용된 샘플 소스 $('div.product').Draggable({revert: true, fx: 300, ghosting: true, opacity: 0.4});
2. Droppables 2.1 Options: accept string mandatory the class name for draggables to get accepted by the droppable activeclass string optional when an acceptable draggable is moved the droppable gets this class hoverclass string optional when an acceptable draggable is inside the droppable, the droppable dets this class tolerance 'pointer', 'intersect' or 'fit' optional points how the draggble must be against the droppable onDrop function optional when an accepted draggble is drop on a droppable this functin is called. Applies to the droppable and gets as parameter the draggable DOMElement onHover function optional called when an accepted draggble is hovering a droppable. Applies to the droppable and gets as parameter the draggable DOMElement onOut function optional called when an accepted draggble is leaving a droppable. Applies to the droppable and gets as parameter the draggable DOMElement 2.2 사용된 샘플 소스 $('#cart').Droppable(

{

accept : 'product',

activeclass: 'activeCart',

hoverclass: 'hoverCart',

tolerance: 'intersect',

onActivate: function(dragged)

{

if (!this.shakedFirstTime) {

$(this).Shake(3);

this.shakedFirstTime = true;

}

},

onDrop: addProductToCart

}

);
재밌네요. 좀 더 공부한다면 더 좋은 인터페이스, 더 많은 문제점을 알게 될 것 같네요. 아직은 모르는 부분이 많아서인지 기본 기능만 되어도 좋아 보이네요. jQuery 다시 보았어...^^

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

CSS Text Gradients  (0) 2009.01.04
jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
가볍고 쉬운 Ajax - jQuery 시작하기  (0) 2008.12.14
renderCalendar  (0) 2008.12.14
플러그인 소개 demo  (0) 2008.12.14
JQuery를 이용한 겸손한 탭 메뉴 구현  (0) 2008.11.16
imgAreaSelect Examples  (0) 2008.11.15
by Anna 안나 2008. 12. 14. 19:30

시작 하기 전에 jQuery는 2006년 초에 John Resig가 개발한 자바스크립트 라이브러리 이다. 전체 라이브러리가 55kb밖에는 안되는 초 경량이면서도 누구나 쉽게 브라우져 기반의 자바스크립트 프로그래밍을 쉽게 할 수 있을 뿐더러, Ajax또한 쉽게 구현 할 수 가 있다. 또한 플러그인 방식의 확장을 지원하여, 현재 많은 수의 플러그인을 확보하고 있다. 나온지는 얼마 안되었지만 수백여개의 사이트가 사용할 만큼 안정적이며, 유명한 라이브러리 이다. 구지 비교하자면 prototype이라는 기존 유명 라이브러리와 비교가 가능하겠지만, 더욱 간단하며, 쉽다는것을 장점으로 꼽고 있다.(사실 본인은 prototype을 잘 모른다. 따라서 기존 개발자들의 의견을 빌린것이다. 어느것이 더 좋다는 표현이 아님을 알아달라) 무엇이 짧은 시간안에 jQuery를 유명하게 하였을까? 이런 호기심을 가지고 깊이 살펴본 결과 그 이유를 알 수 있었다. 작고, 쉽고, 그러나 강력하다는 것이 그 이유이다. 따라서 이런 본인의 경험을 공유하고자 이글을 올린다. 이 글은 jQuery의 튜토리얼문서를 기반으로하여 작성 되었다. 따라서 예제의 상당 부분은 동일하다, 단, 직접 프로그래밍을 통해 소스를 돌려보고 그 경험을 글로 올리는것이니 만큼 그냥 번역 보다는 더 나을 것으로 판단 한다. 참고로 이글에서 Ajax는 비동기 통신의 경우에만 국한 하겠다. 그 이유는 jQuery에서 Ajax라는 별도 네임스페이스로 라이브러리를 지원하기 때문이다. 자바스크립트 전용 IDE 소개 - Aptana 프로그래머들 중에는 IDE를 싫어하는 사람도 있다. 그러나 나는 없는것보다는 있는것이 더 낳다고 생각한다. 특히 한 언어를 위한 전용 환경을 지원할 경우는 더욱 그러하다. 브라우져 기반의 자바스크립트 프로그래밍을 하다보면 가장 어려운 점이 디버깅이다. printf디버거도 어려울 경우가 많다.(printf디버거는 디버깅을 위해 필요한 값을 출력하여 확인 하는 방법을 말한다.-본인이 만들어낸 용어이다.) 특히 브라우져의 경우는 로컬파일을 사용할 수 없어 화면을 이용한 값의 출력에 의존하여야 함으로 루프값을 출력할 경우는 거의 죽음이고, HTML태그를 생성하여 이곳에 이벤트를 결합하고, 코딩하는것을 반복하는 동적 HTML프로그래밍은 더욱 디버깅이 어렵다. 따라서 브라우져의 플러그인과 결합된 디버거를 사용하는것이 매우 도움이 된다. Firefox용 Firebug가 대표적인 것인데, 가장 많이 사용하는 디버거 이기도 하다. 그러나 편집기와 독립된 형태로 사용해야 함으로 수정 작업 시 불편함이 따른다. 이러한 점을 개선하려면 역시 디버거와 편집기를 포함하는 전용 IDE가 필요하다. 한가지더 이야기 하면, 기존 Eclipse와 같은 IDE에서 지원하는 Code Inspector기능의 필요를 들 수 있다. 사실 한 언어에 익숙한 사람이면 이 기능이 불편 하다. 매번 객체명뒤 점을 찍어 객체의 맴버를 보는 것은 그것을 아는 사람에게는 편집속도만 떨어뜨릴 뿐이다. 그러나 언어에 익숙치 않다거나, 남이 제공한 라이브러리를 사용할 경우는 이기능이 매우 유용하다. 특히 해당 맴버의 간단한 도움말까지 표시되면 API문서를 일일이 그때마다 검색하지 않아도 되어서 편리하다. 기존 자바 스크립트 편집기는 사실 이러한 기능이 부족한것이 사실 이었다. 그러나 지금 소개할 Aptana는 자바스크립트 전용 IDE를 표방한 몇 안되는 IDE중 하나이다. 이클립스 기반에 프러그인으로 개발되고 배포는 리치클라이언트와 플러그인 방식 모두를 지원한다. 따라서 기존 설치된 이클립스에서도 사용할 수 있고, 별도 설치를 통해 독립적인 IDE로 사용 할수도 있다. 다음은 Aptana의 실행 화면이다.


특히 Code Inspector가 매력 적이다. 노란 색으로 나오는 도움말도 매우 유용하다.
Apatana의 설치는 쉽다. 또한 무료로 사용 할 수 가 있다. (http://www.aptana.org/) 사용법은 기존 Eclipse와 동일하다. 단 디버거를 사용하려면 Firefox가 설치 되어 있어야 한다. 또한 기존 Ajax라이브러리들도 지원하는데, jQuery도 지원한다. 위 화면에서 객체의 도움말이 나올 수 있는것은 이 때문이다. 프로젝트 생성 시 jQuery프로젝트를 선택하여 생성 하면 된다. jQuery 사용 위에서 소개한 Aptana를 설치 하였다면, 별도 jQuery설치는 필요 없다. 하지만 설치가 어려운것은 아니다. jQuery라이브러리는 55kb짜리 파일 하나로 되어 있다. 이를 HTML에 사용 선언을 하여 주면 된다. <html>
<head>
<script type="text/javascript" src="path/jquery.js"></script>
<script type="text/javascript">
// Your code goes here
</script>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
</body>
</html> 기존 자바 스크립트 라이브러리 사용과 차이가 없다. 단, 압축버젼과 그렇지 않은 버젼 두개의 파일을 제공하는데, 프로그래밍을 할 때는 디버깅을 위해 압축하지 않은 버젼의 파일을 사용하고, 배포할 경우 압축된 버젼을 사용하는 것이 좋다. jQuery 의 시작 이벤트 보통의 자바스크립트 프로그래머들은 브라우져의 document가 모두 다운로드 되어진 상태에서 코드를 시작하기위해 다음과 같은 이벤트에 스크립트 코드를 넣는다. window.onload = function(){ ... } 그러나 이 경우 이미지 까지 다운로드가 모두 완료 된 후 이벤트가 호출되기 때문에, 큰이미지의 경우 실행속도가 늦은 것처럼 사용자에게 보일 수 있다. 따라서 jQuery는 이러한 문제를 해결하기위해 다음과 같은 이벤트를 제공한다. $(document).ready(function(){
// 이곳에 코드를 넣으면 된다.
}); 이 이벤트는 브라우져의 document(DOM)객체가 준비가 되면 호출이 된다. 따라서 이미지 다운로드에 의한 지연이 없다. 위 코드는 다음과 같이 생략하여 사용 가능하다. $(function() { // run this when the HTML is done downloading }); 사용자 이벤트 처리 - 클릭이벤트의 예 특정 태그를 클릭 했을경우 이벤트의 처리를 jQuery에서 어떻게 처리 하는지를 살펴 보자. 다음은 위 HTML예제의 앵커(a)태그 클릭 시 이벤트를 처리하는 코드 이다. $("a").click(function(){
alert("Thanks for visiting!");
}); jQuery에서 이벤트 처리는 콜백함수를 통해 수행된다. 이코드는 HTML에 있는 모든 앵커 태그의 클릭 시 ?업창을 통해 메시지를 출력해 준다. 코드를 보면 $()로된 문법을 볼 수 있을 것이다. 이것은 jQuery의 셀렉터 이다. $("a")가 의미하는 것은 HTML(브라우져의 DOM)에서 앵커태그 모두를 의미한다. 이후 .click()메소드는 이벤트 메소드로서 이곳에 콜백함수를 파라메타로 넣어 이벤트 처리를 수행 하는것이다. 함수는 위에서 처럼 익명(function(){...})이나 선언된 함수 모두를 사용할 수 있다. jQuery의 셀렉터 $()로 시작하는 셀렉터를 좀더 살펴보자. jQuery는 HTML, DOM객체등을 CSS나 XPATH의 쿼리방법과 동일한 방법으로 선택 한다. 앞선 예처럼 문자열로 특정 태그를 선택하는 것은 CSS를 작성해 본 프로그래머라면 익숙할 것이다. 이와 같은 방법 외에도 다음과 같이 태그의 id를 통해 선택 할 수 있다. $(document).ready(function() {
$("#orderedlist").addClass("red");
}); 위 코드는 id가 orderedlist인 태그에 red라는 CSS 클래스를 할당하는 코드 이다. 만약 이태그가 하위 태그를 가지고 있다면 다음과 같이 선택 할 수 있다. $(document).ready(function() {
$("#orderedlist > li").addClass("blue");
}); 이코드는 id가 orderedlist인 태그의 하위 태그 중 <li> 태그 모두에 blue라는 CSS 클래스를 할당하는 코드 이다. 이코드는 jQuery메소드를 이용 다음과 같이 바꾸어 사용 할 수도 있다. $(document).ready(function() {
$("#orderedlist").find("li").each(function(i) {
$(this).addClass("blue");
});
}); 한가지 다른 점은 모든 태그에 동일하게 CSS 클래스를 적용하는 방식이 아닌 개별 태그를 선택하여 적용할 수 있다는 것이다. XPath를 사용하는 예를 다음과 같은 것을 들 수 있다 //절대 경로를 사용하는 경우 $("/html/body//p")
$("/*/body//p")
$("//p/../div") //상대경로를 사용하는 경우 $("a",this)
$("p/a",this) 다음과 같이 두 방식을 혼용하여 사용 할 수도 있다. //HTML내 모든 <p>태그중 클래스속성이 foo인 것 중 내부에 <a> 태그를 가지고 있는것 $("p.foo[a]"); //모든 <li>태그 중 Register라는 택스트가 들어있는 <a> 태그 $("li[a:contains('Register')]"); //모든 <input>태그 중 name속성이 bar인 것의 값 $("input[@name=bar]").val(); 이외에도 jQuery는 CSS 3.0 표준을 따르고 있어 기존 보다 더많은 쿼리 방법을 지원하고 있다. 자세한것은 jQuery의 API 설명을 참고 하라(http://docs.jquery.com/Selectors) Chainability jQuery는 코드의 양을 줄이기 위해 특별한 기능을 제공한다. 다음 코드를 보자 $("a").addClass("test").show().html("foo"); <a>태그에 test라는 CSS 클래스를 할당한다. 그후 태그를 보이면서 그안에 foo라는 텍스트를 넣는다. 이런 문법이 가능한 이유는 $(), addClass(), show()함수 모두가 <a>태그에 해당하는 객체를 결과로 리턴해주면 된다. 이를 Chainability라 한다. 좀더 복잡한 경우를 보자 $("a")
.filter(".clickme")
.click(function(){
alert("You are now leaving the site.");
})
.end()
.filter(".hideme")
.click(function(){
$(this).hide();
return false;
})
.end(); // 대상 HTML이다 <a href="http://google.com/" class="clickme">I give a message when you leave</a>
<a href="http://yahoo.com/" class="hideme">Click me to hide!</a>
<a href="http://microsoft.com/">I'm a normal link</a> 중간에 end()함수는 filter()함수로 선택된 객체를 체인에서 끝는 역할을 한다. 위에서는 clickme클래스의 <a>태그 객체를 끊고 hideme를 선택하는 예이다. 또한 this는 선택된 태그 객체를 말한다. 이런 Chainability를 지원 하는 jQuery메소드들에는 다음과 같은 것들이 있다. add() children() eq() filter() gt() lt() next() not() parent() parents() sibling() Callbacks 위에서 click()이벤트를 콜백함수를 통해처리하는 코드를 살펴 보았다. 콜백함수는 기존 자바나 .NET의 그것과 같다. 다음 코드를 보자 $.get('myhtmlpage.html', myCallBack); 먼저 $.get()은 서버로 부터 HTML(또는 HTML 조각)을 가져오는 함수 이다. 여기서 myCallBack함수는 전송이 완료 되면 호출되는 콜백 함수 이다. 물론 앞선 예의 click()이벤트 콜백처럼 익명함수 function(){}을 사용 해도 된다. 그러나 이와 같이 미리 선언된 함수를 콜백으로 사용할 경우 파라메타의 전달 방법은 좀 다르다. 흔히 다음과 같이 하면 될것이라 생각할 것이다. $.get('myhtmlpage.html', myCallBack(param1, param2)); 그러나 위와 같은것은 자바스크립트의 클로져(closure)사용에 위배가 된다. 클로져는 변수화 될수 있는 코드 블록을 이야기한다. 즉 스트링변수와 같이 파라메타로 전달될 수 있지만, 실행가능한 함수 인 것이다. 일반적으로 함수를 ()제외하고 이름만을 사용하면 클로져가 된다. 위의경우 $get()함수의 파라메타로 전달된 myCallBack함수는 클로져로 전달된것이 아닌 myCallBack()를 실행한 결과 값이 전달 된다. 따라서 다음과 같이 코드를 작성하여야 한다. $.get('myhtmlpage.html', function(){
myCallBack(param1, param2);
}); 만약 선언된 함수가 아닌 익명함수를 콜백으로 사용할경우는 다음과 같이 하면 된다. $.get('myhtmlpage.html', function(param1, param2){
//이곳에 코드를 넣는다.
}); jQuery 의 애니메이션 HTML의 태그를 사라지고 나타내게 하거나, 늘리고 줄이고, 이동시키는 애니매이션 동작은 많이 사용하는 기는 중 하나이다. jQuery는 다양안 애니메이션 기능을 메소드를 통해 제공한다. 다음 코드를 보자 $(document).ready(function(){
$("a").toggle(function(){
$(".stuff").hide('slow');
},function(){
$(".stuff").show('fast');
});
}); 이코드는 <a>태그중 stuff클래스가 할당된것을 토글로 느리게 감추고, 빨리 보이게 하는 함수 이다. 다음은 animate()메소드를 이용하여 여러 애니메이션을 합쳐 실행하는 예이다. $(document).ready(function(){
$("a").toggle(function(){
$(".stuff").animate({ height: 'hide', opacity: 'hide' }, 'slow');
},function(){
$(".stuff").animate({ height: 'show', opacity: 'show' }, 'slow');
});
}); 위 코드는 높이와 투명도를 동시에 천천히 사라지고, 나타나게 하는 코드 이다. jQuery에서의 Ajax Ajax는 서버와의 비동기 통신을 말한다. 일반적으로 Ajax하면 요즘은 자바스크립트를 이용한 브라우져의 동적 DOM의 처리, 즉 DHTML, CSS등을 포함하지만, jQuery에서는 Ajax라는 네임스페이스를 통해 비동기 서버 통신을 하는것을 말한다.먼저 다음 예를 보자 $.ajax({
type: "GET",
url: "test.js",
dataType: "script"
}) 이 예는 GET방식으로 서버에서 자바스크립트를 로딩하고 실행하는 코드 이다. 다음 예를 보자 $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
}); 이는 서버로 부터 POST방식으로 파라메터를 주어 데이터를 가져온 후 이를 success콜백을 이용해 처리하는 코드이다. 아마 Ajax에서 가장 많이 사용하는 코드일 것이다. success말고도 $.ajax()함수는 다양한 옵션을 제공한다. 자세한 내용은 API설명을 참조하라 (http://docs.jquery.com/Ajax) 다음 예는 이 옵션 중 async(비동기)방식을 사용할지 아닐지를 사용한 코드이다. var html = $.ajax({
url: "some.php",
async: false
}).responseText; 맺으며... 지금까지 jQuery에 대해 간단히 살펴 보았다. 혹자는 Dojo나 Extjs와 같이 버튼, 그리드등의 위젯이 지원되지 않는다고 실망할 것이다.그러나 jQuery는 Plugin을 지원한다. 이중 Interface와 같은 플러그인은 그 완성도가 매우 높다. 이것 말고도 수백개의 플러그인들이 홈페이지를 통해 공개 되어 있다.(http://docs.jquery.com/Plugins) 하지만 내 경험상으로 그리드와 같은 복잡한 위젯이 아니더라도 자바스크립크를 이용한 동적인 홈페이지와 Ajax를 통한 비통기 통신만으로도 대부분의 고객 요구와 문제를 해결 할 수 있다. 실제로 jQuery는 MSNBC와 같은 유명한 많은 사이트에서 사용되고 있다.(http://docs.jquery.com/Sites_Using_jQuery) 따라서 어떤 서비스를 제공하느냐에 따라 필요한 위젯을 플러그인을 사용하거나 직접 개발하여 사용하는것이 더 나은 전략이라 생각한다. 사실 미리 만들어진 위젯도 나에게 맞추어 사용하기 위해서는 그래픽, CSS등 많은 부분을 손 대야 한다. 차라리 기본 원리를 알고 이를 확장하는 것이 좀더 전문적이고 어려운 문제를 해결 할 수 있는 길이라 생각 한다. 시간이 허락 한다면 꾸준히 jQuery의 개발 경험을 공유 하고 싶은 마음 이다.

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

jQuery 강좌 링크  (0) 2008.12.14
InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
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
by Anna 안나 2008. 12. 14. 19:23
Page sourcecode $(function()
{
// update the firstDayOfWeek when the day of week select changes
$('#dow').bind(
'change',
function()
{
Date.firstDayOfWeek = Number(this.options[this.selectedIndex].value);
}
);
// when the choose date form is submitted grab the chosen month and year
// from the select elements and call renderCalendar...
$('#chooseDateForm').bind(
'submit',
function()
{
var month = Number(this.month.options[this.month.selectedIndex].value);
var year = Number(this.year.options[this.year.selectedIndex].value);

$('#calendar-me').renderCalendar({month:month, year:year});

return false;
}
);
});

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

InnerFade with JQuery  (0) 2008.12.14
jQuery Corner Demo  (0) 2008.12.14
jQuery Treeview Plugin Demo  (0) 2008.12.14
jQuery를 이용한 쇼핑카드 예제  (0) 2008.12.14
가볍고 쉬운 Ajax - jQuery 시작하기  (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-프로토타입, jQuery에서 간단히 충돌 피하기  (0) 2008.11.15
by Anna 안나 2008. 12. 14. 19:22
테이블에 대한 플러그인 demo http://motherrussia.polyester.se/docs/tablesorter/ 정렬기능만 http://p.sohei.org/stuff/jquery/columnmanager/demo/demo.html colum을 안보이게 할수 있음 http://ptdateselect.sourceforge.net/example/sample001.html 선택하여 수정가능 http://makoomba.altervista.org/grid/ 보기만 가능(마우스 갖다대면 색 변화) http://ideamill.synaptrixgroup.com/jquery/tablefilter/tabletest.htm 필터기능 http://www.webtoolkit.info/demo/jquery/scrollable/demo.html 그리드에 스크롤바 http://projects.arkanis-development.de/table_navigation/example.html 다른페이지 링크 http://www.dyve.net/jquery/?editable 수정가능 Multi-Column Client-Sortable Dropdown Select Box 페이지가 리스트로 페이지 또는 메뉴에 대한 플러그인 http://stilbuero.de/jquery/tabs/#fragment-29 tag http://rikrikrik.com/jquery/pager/#download *페이지 처리 http://jdsharp.us/jQuery/plugins/jdMenu/1.3.beta2/jdMenu-demo.html 체크박스 http://jquery.bassistance.de/validate/demo-test/radio-checkbox-select-demo.html http://labs.freakdev.com/jquery/fCheck/pizza.php http://kawika.org/jquery/checkbox/ 폼 http://www.lexcat.ro/nicejforms/nicejforms.html http://jquery.bassistance.de/validate/demo-test/ 회원등록 http://jquery.bassistance.de/validate/demo-test/errorcontainer-demo.html 로그인,파일첨부 http://jquery.bassistance.de/validate/demo-test/ajaxSubmit-intergration-demo.html 로그인 유효성 검사 http://jquery.bassistance.de/validate/demo-test/custom-methods-demo.html 필드 유효성 검사 http://www.studioindustryllc.com/icontact.html Security Code 달력 http://marcgrabanski.com/code/jquery-calendar/ http://kelvinluck.com/assets/jquery/datePicker/v2/demo/ http://pttimeselect.sourceforge.net/example/index.html timeselect 미디어 http://jquery.lukelutman.com/plugins/flash/example-basic.html flash 넣기 http://www.sean-o.com/jquery/jmp3/ mp3 파일넣기 http://malsup.com/jquery/media/video.html 미디어 박스 창 띄우기 http://jquery.com/demo/thickbox/ http://www.aspstat.com/jbox/demo.htm 박스 창띄기기(크기조절가능) http://dev.iceburg.net/jquery/jqModal/ 화면 waiting http://malsup.com/jquery/block/#page 스크롤바 http://kelvinluck.com/assets/jquery/jScrollPane/jScrollPane.html 문서보기 http://malsup.com/jquery/media/misc.html 플래쉬효과 http://medienfreunde.com/lab/innerfade/#n2 tip http://www.codylindley.com/blogstuff/js/jtip/, http://edgarverle.com/BetterTip/default.cfm http://www.dave-cohen.com/node/1186 http://jquery.bassistance.de/tooltip/ icon http://icon.cat/software/iconDock/ 구글 지도 http://www.dyve.net/jquery/?googlemaps http://projects.sevir.org/storage/jqmaps/index.html 기타 color선택 http://www.wanderinghorse.net/computing/javascript/jquery/colorpicker/demo-colorpicker.html text에 highlightFade http://jquery.offput.ca/highlightFade/ 박스 resize http://dev.iceburg.net/jquery/jqDnR/ 박스 애니메이션 http://dev.jquery.com/~paul/plugins/animateClass/
by Anna 안나 2008. 12. 14. 19:21
이번에 사이트를 개편하면서, 탭 메뉴로 구성된 추천 글 목록을 추가했습니다. 제 사이트의 방문자 통계를 확인하니, 방문자들의 이동 경로가 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
| 1 2 3 4 5 |