2013-04-23 2 views
0

IE9에서이 문제의 해결 방법을 찾을 수 있는지 알아야 할 필요가 있으면 chrome/firefox에 완벽하게 표시되고 값은 다음과 같이 변경됩니다. 그것은 기대되지만 div는 높이를 확장하지 않습니다.jquery toggleClass가 CSS 속성을 변경할 때 IE에서 작동하지 않지만 입력 값을 변경할 때 수행

이 코드는 외부 .js 파일에 있으며 나는 html로 직접 사용하려하지 않았습니다.

HTML

<div class="active-collapsed">Some stuff here</div> 

CSS

.active-collapsed {height:345px;} 
.active-expanded {height:690px;} 
#exp-btn {margin-bottom:5px;width:80px;} 

의 jQuery v1.7.2

$(document).ready(function() { 

    jQuery('#exp-btn').click(function() { 
     $(".active-collapsed").toggleClass("active-expanded"); 


     if ($(this).val() == "+ profiles") { 
      $(this).val("- profiles"); 
     } else { 
      $(this).val("+ profiles"); 
     } 
    }); 

}); 
+3

도 당신의 HTML과 CSS를하시기 바랍니다습니다. –

+0

어떤 jQuery 버전을 사용하고 있습니까? –

+0

간단한 수수께끼 http://jsfiddle.net/4UGck/2/ 심지어 이전 버전의 jquery에서 작동합니다. –

답변

0

http://jsfiddle.net/4UGck/4/은 IE9에서 완벽하게 작동합니다. 내가 한 일은 val()을 text()로 변경하고 오버플로를 추가 한 것입니다 : css에 숨겨져 있습니다.

$(function(){ 
    $('#exp-btn').click(function() { 
     $(".active-collapsed").toggleClass("active-expanded"); 


     if ($(this).text() == "+ profiles") { 
      $(this).text("- profiles"); 
     } else { 
      $(this).text("+ profiles"); 
     } 
    }); 

}); 

그리고 CSS

.active-collapsed {height:345px; overflow: hidden;} 
관련 문제