티스토리 뷰
제이쿼리에 대해 자세히 설명된 부분이 있어 포스팅합니다. ^^
동작 방식
$('p') : HTML 파일 내의 모든 문단 엘리먼트를 접근
$('div') : HTML 파일 내의 모든 div 엘리먼트를 접근
$('#A') : id=A 인 모든 HTML 엘리먼트를 접근
$('.b') : class=b 인 모든 HTML 엘리먼트를 접근
$('p') : HTML 파일 내의 모든 문단 엘리먼트를 접근
$('div') : HTML 파일 내의 모든 div 엘리먼트를 접근
$('#A') : id=A 인 모든 HTML 엘리먼트를 접근
$('.b') : class=b 인 모든 HTML 엘리먼트를 접근
엘리먼트에 CSS 적용하기
.css {
font-size:11px;
backgroudn-color:#fff;
}
$('div').addClass('css');
$('div').addClass('css');
.css {
font-size:11px;
backgroudn-color:#fff;
}
$('div').addClass('css');
$('div').addClass('css');
이벤트 처리로 텍스트 추가 또는 제거하기
<script type="text/javascript">
$(document).ready(function() {
$('.add').click(function(){
$('.pp').prepend('<p>추가하기를 누르면 텍스트가 추가됩니다.</p>'); // 문단을 추가할 때는 prepend() 메소드를 사용합니다.
});
$('.remove').click(function(){
$('p').remove(); //문단 엘리먼트를 제거할 때는 remove() 메소드를 사용합니다.
});
});
< /script>
<script type="text/javascript">
$(document).ready(function() {
$('.add').click(function(){
$('.pp').prepend('<p>추가하기를 누르면 텍스트가 추가됩니다.</p>'); // 문단을 추가할 때는 prepend() 메소드를 사용합니다.
});
$('.remove').click(function(){
$('p').remove(); //문단 엘리먼트를 제거할 때는 remove() 메소드를 사용합니다.
});
});
< /script>
맨위로 링크 만들기
$(document).ready(function() {
$('<a href="#topofpage">Return to top</a>').insertAfter('p');
$('<a id="topofpage" name="topofpage"></a>').prependTo('body');
});
Return to top 이라는 텍스트를 가진 링크를 html의 모든 문단 엘리먼트 뒤에 붙여서 사용자가 링크를 클릭하면 id가 topofpage인 엘리먼트로 이동할 수 있게 합니다.
$(document).ready(function() {
$('<a href="#topofpage">Return to top</a>').insertAfter('p');
$('<a id="topofpage" name="topofpage"></a>').prependTo('body');
});
Return to top 이라는 텍스트를 가진 링크를 html의 모든 문단 엘리먼트 뒤에 붙여서 사용자가 링크를 클릭하면 id가 topofpage인 엘리먼트로 이동할 수 있게 합니다.
더 읽기 숨기기 만들기
$(document).ready(function() {
$('.message').hide(); //message 클래스를 숨깁니다.
$('span.readmore').toggle(function(){
$('.message').show('slow');
$(this).text("숨기기"); //readmore를 숨깁니다.
},
function(){
$('.message').hide('slow');
$(this).text("더읽기");
});
});
$(document).ready(function() {
$('.message').hide(); //message 클래스를 숨깁니다.
$('span.readmore').toggle(function(){
$('.message').show('slow');
$(this).text("숨기기"); //readmore를 숨깁니다.
},
function(){
$('.message').hide('slow');
$(this).text("더읽기");
});
});
텍스트에 애니메이션 효과 넣기
$(document).ready(function(){
$('.content01').hide();
$('.content02').hide();
$('.content03').hide();
$('.button01').click(function(){
$('.content01').show('slow');
$('.content02').hide();
$('.content03').hide();
});
$('.button02').click(function(){
$('.content02').show('slow');
$('.content01').hide();
$('.content03').hide();
});
$('.button03').click(function(){
$('.content03').show('slow');
$('.content02').hide();
$('.content01').hide();
});
});
$(document).ready(function(){
$('.content01').hide();
$('.content02').hide();
$('.content03').hide();
$('.button01').click(function(){
$('.content01').show('slow');
$('.content02').hide();
$('.content03').hide();
});
$('.button02').click(function(){
$('.content02').show('slow');
$('.content01').hide();
$('.content03').hide();
});
$('.button03').click(function(){
$('.content03').show('slow');
$('.content02').hide();
$('.content01').hide();
});
});
'Resource' 카테고리의 다른 글
무료법률서비스 (0) | 2013.04.27 |
---|---|
CSS3 미디어 쿼리를 이용한 Responsive 페이지 만들기 (0) | 2013.04.27 |
jQuery CSS3를 이용한 12달 달력 코딩하기 (0) | 2013.04.27 |
제이쿼리, html5, css3를 이용한 비디오 플레이어 (0) | 2013.04.27 |
풀스크린으로 화면 전환효과 슬라이드 만들기 (0) | 2013.04.27 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 아이프레임
- 모바일 웹
- CSS
- 모바일
- HTML5
- 창업
- 마이크로소프트
- 세미나
- 마케팅
- 무료스킨
- 자바스크립트
- 2013
- 모바일웹
- 제이쿼리
- 플러그인
- 벤처
- Adobe
- 티스토리
- 소치올림픽
- 태그를 입력해 주세요.
- 뮤직컬
- 모터스포츠
- 무료
- 워드프레스
- CSS3
- 포스코
- 웹표준
- 마켓플레이스
- 쿼크모드
- jquery
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함