2013-01-20 5 views
2

확인란에 포커스가있을 때 체크 박스 입력에 부트 스트랩을 만들고 싶습니다.포커스가 jquery 일 때 부트 스트랩 툴팁이 작동하지 않습니다.

HTML

<label class="checkbox inline"><input type="checkbox" class="centang-semua-faktur tooltip-atas" rel="tooltip"> <b>Cetak</b></label> 

JQuery와

var $checkAllFaktur = $('.centang-semua-faktur'); 

    $checkAllFaktur.on('focus', function() { 
     if ($(this).is(':checked')){ 
      $checkAllFaktur.attr('title', 'Hapus Centang Semua').tooltip(); 
     }else{ 
      $checkAllFaktur.attr('title', 'Centang Semua').tooltip(); 
     } 
    }); 

좀 도와주세요 : 그래서 이것은 내 만든 코드입니다. 고마워요 :)

답변

2

시나리오에서는 툴팁을 showdestroy으로 지정해야합니다. 기본값은 mouseenter에서만 표시되고 mouseout에서는 표시되지 않습니다.

또한 포커스 이벤트를 click 이벤트에 바인딩하여 키보드 만 사용하는 것이 아니라 마우스를 사용할 때 초점이 맞춰 지도록해야합니다.

var $checkAllFaktur = $('.centang-semua-faktur'); 

$checkAllFaktur 
.on('click', function() { 
    $(this).trigger('focus') 
}) 
.on('focus', function() { 
    if ($(this).is(':checked')){ 
     $checkAllFaktur.attr('title', 'Hapus Centang Semua').tooltip('show'); 
    }else{ 
     $checkAllFaktur.attr('title', 'Centang Semua').tooltip('show'); 
    } 
}) 
.on('blur', function(){ 
    $(this).tooltip('destroy'); 
}); 

근무 예 : http://jsfiddle.net/MgcDU/1398/

관련 문제