티스토리 뷰

http://jquery.com/  http://docs.jquery.com/Downloading_jQuery


광범위하게 사용되는 자바스크립트 ajax

이름이 암시하는 것처럼 query 에 초점을 맞춘 라이브러리

jQuery 의 특징 
• An expressive syntax (CSS selectors) for referring to elements in the document
• An efficient query method for finding the set of document elements that match a CSS selector
• A useful set of methods for manipulating selected elements
• Powerful functional programming techniques for operat-ing on sets of elements as a group, rather than one at a time
• A succinct idiom (method chaining) for expressing sequences of operations


jQuery 용어 
the jQuery function : jQuery(), $()
the global jQuery object : jQuery의 유일한 글로벌 객체
jQuery 또는 $ 의 function 이다.
이 함수는 jQuery object를 생성하고 DOM 이 ready 될때 호출되는 핸들러를 등록시킨다.
jQuery의 namespce의 역할도 한다.

a jQuery object
; jQuery result, jQuery set, wrapped set
jQuery function 에 의해 리턴되는 객체
 - 속성 3가지 : selector, context, jquery
 - 배열의 경우 속성 length 완 numeric(0 ~ length-1)을 갖는다. 
document elements의 집합으로 표현된다. 
method-chaining idiom : define many methods for operating on the sets of elements they represent 

• the selected elements
When you pass a CSS selector to the jQuery function, it
returns a jQuery object that represents the set of docu-
ment elements matching that selector. When describing
the methods of the jQuery object, I’ll often use the phrase
“the selected elements” to refer to those matching ele-
ments. For example, to explain the  attr() method, I
might write, “the attr() method sets HTML attributes
on the selected elements”, rather than a more precise but
awkward description like, “the  attr() method sets
HTML attributes on the elements of the jQuery object on
which it was invoked”. Note that the word “selected” re-
fers to the CSS selector and has nothing to do with any
selection performed by the user.
 
• a jQuery function
the jQuery function 의 namespace 안에 정의된다.
static methods 로도 표현됨
예>$.each(a, f) : each function 
 
• a jQuery method
the jQuery function에서 리턴된 jQuery object 의 method
$("a).each(f) : each method 


jQuery() 사용법
1.$()에 CSS selector (a string) 를 전달 
 
2.$() 에  Element, Document, or Window object 를 전달 

3.$() HTML text를 전달 
var img = $("<img/>", // Create a new tag
                 { src:url, // With this src attribute alt:desc }); // And this alt attribute
4.$() 에 함수를 전달
If you do this, the function you pass will be invoked when the
document has been loaded and the DOM is ready to be manipulated. 
참고 :
You’ll sometimes see $(f) written using the older and more
verbose form: $(document).ready(f). 
jQuery(function() { // Invoked when document has loaded
                            // All jQuery code goes here });

 
댓글