본문 바로가기

Local Oriented/jQuery

jQuery, each, click, toggle 을 몽땅 사용해서..


$('..').each(function(){
  $(this).click(function(){
    $(this).toggle(function(){
      $(this).css('background-color','#9678bf');
    });
  });
});

$('..').bind('click',function(){
  $(this).toggle(function(){
    $(this).css('background-color','#9678bf');
  });
});


$('..').each(function(index){
  // 여기서 index 는 each 에 잡히는 개체의 순서. 0, 1, 2, ...
}); 


cf. jquery index  클릭해 보세요..