2012-08-24 2 views
1

목록 항목 안에 목록 항목에 대해 작동하지 않습니다 "델 - 디스플레이"그래서 그것은 오렌지로 색상을 변경합니다. 그러나, 항목이 자체 내 토글 코드를 저장하고 실행할 때 표시되지 않습니다jQuery를 토글 내가 목록 항목 안에 목록이

$(".sel-display").toggle(function() { 
      $(this).css("background", "#ffcc00"); 
      //$(this).css("background-position", "140px 5px"); 
    });​ 

나는 바이올린 여기했습니다 : http://jsfiddle.net/noscirre/3fwZn/

어떤 도움이 많이 이해할 수있을 것이다.

+2

. http://api.jquery.com/category/deprecated/ – j08691

+2

호버를 토글하고 있습니까? 딸깍 하는 소리? 토글을 유발하는 것은 무엇입니까? –

+0

jsFiddle이 jQuery 대신 MooTools를 포함하고있는 것처럼 보입니다. P –

답변

0

귀하는이 같은 것을 할 수있는 :

$('.sel-display').click(function(){ 
    if($(this).hasClass("highlighted")){ 
     $(this).removeClass("highlighted"); 
     $(this).css({"background", "#ffffff"}); 
    }else{ 
     $(this).addClass("highlighted"); 
     $(this).css({"background", "#ffcc00"}); 
    } 
}); 
0

난 당신과 같은 특정 클래스 이름이 뭔가 모든 목록 항목에 발견 할 필요가 있다고 생각 다음 메신저 무료 손을 쓰기 때문에 그게 전부 코드 올바른 경우

$('.sel-display').find('li').hasClass('del-display'); 

임 확실하지하지만 난 당신을 생각 그 선을 따라 뭔가가 필요할지도 모른다.

0

하지 최고의 솔루션을,하지만 뭔가?

http://jsfiddle.net/3fwZn/7/

자바 스크립트 :

$(".sel-display").click(function() { 
    $(this).toggleClass('del'); 
}); 

CSS : 토글의 사용이 중지되었습니다

.del { 
    background-color: #ffcc00 !important; 
}