2009년 6월 17일 수요일

JQuery 사용팁 모음.


JQuery 를 사용하면서, 자주 쓰이고 제일 유용한것들(?) 정리..

아마 이정도면 JQuery 로 왠만한건 구현 가능할듯?



[code]

//초기 실행
$(document).ready(function() {
   init();
})


//onclick 설졍
$('id').click( function(){
    alert('click!!');
})


//onchange 설졍
$('id').change( function(){
    alert('click!!');
})


//CSS변경
$('id').css('style', 'attribute');


//첫번째 tr를 빼고 전부 삭제
$
('someTableSelector tr:not(:first)').remove();


//select 세팅
$("id option[value=Apple]").attr("selected", "true");


//selected 값
$("id :selected").val()


//table 안에 tr추가
$('id').append( $('<tr></tr>').html('<td>JQuery</td>');


//swfobject 플러그인 사용.
    $('#flashcontent').flash(
        {
            swf: 'fla/cp.swf',
            width: 820,
            height: 250,
            flashvars:
            {

               
name1: 'jQuery',
                name2: 'SWFObject',
                name3: 'Plugin'

            }
        }
    );


//

[/code]