jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.-- http://jquery.com/
jQuery를 사용하는 이유!!!
1. 크로스 브라우징이 가능하다!!브라우저별로, 따로 코딩을 해 줄 필요 없이 jQuery를 이용해서 모든 브라우저에 대한 호환이 가능하다.
2. 코드가 간결해진다.
자주 사용하는 함수들을 모두 jQuery에 포함시켜서 간단한 코딩으로 복잡한 작업을 수행할 수 있게 되어 코드가 간결하게 된다.
jQuery의 특징적인 용법
$('tr:first').css('background', '#000000').css('color', '#ffffff').style('font-size', '14px');
jQuery는 함수가 호출 된 뒤에 그 자리에 자기 자신이 리턴되기 때문에 명령을 수행할 때마다 해당 엘리먼트를 검색할 필요 없다. 따라서 검색하는 Performance가 줄어들어 성능이 향상된다.
jQuery의 함수 호출 패턴
1) 객체/함수() >> 값을 꺼내는 호출
2) 객체/함수(값) >> 값을 설정하는 호출
3) 객체/함수(function(){return 값}) >> 함수의 리턴 값으로 값을 설정
4) 객체/함수({key:값, key:값, .....}) >> 한꺼번에 여러개의 값을 설정
값을 꺼낼 때에는 어떤 함수를 사용하더라도 [0]index의 값만을 꺼낸다. 하지만 유일하게 jQuery를 배반하는 함수가 있으니 바로 .text() 되시겠다.
.text() 는 찾은 것들의 값을 모두 string으로 받아서 html규칙, script규칙을 무시하고 문자열로 만들어 꺼내준다.
댓글 없음:
댓글 쓰기