Jquery 1.8부터는 요소의 높이()를 가져올 때 변경되었습니다. CSS div 높이를 %와 auto를 사용하여 div의 높이와 너비를 지시하는 이미지와 함께 자동으로 설정했습니다. 그리고 창로드시 Jquery를 사용하여 요소 높이를 가져오고 옆에 다른 div를 만듭니다. 같은 높이. 이것을 연구 한 후에 나는 CSS가 이미지에 의해 설정된 새로운 높이를 설정하기 전에 높이를 되 돌리는 것으로 나타났습니다. 1.7에서 허용했지만 1.8 이상에서는 허용되지 않습니다. ther는 주위에 일하는가? 이 희망이 의미가, 누군가가 주변에 일이있는 CSS를jquery 1.8 이상에서는 div의 높이를 다른 div와 동일하게 설정하십시오
#element1{ width:80%; height:auto;}
#element1 img{width:100%; height:auto};//this allows the image to resize with the page responsively.
jQuery를 ...
$(window).ready(
function(){
var x = $("#element").height();
alert(x); // this would return what the height was dynamically set as by the css in 1.7, but 1.8 returns a small number that i am pretty certain is just the padding added to 0px
});
입니다. 감사합니다.
바이올린을 설정하면 더 도움이 될 수 있지만'.outerHeight()'를 시도해보십시오. – elzi
'.outerHeight()'는 좋은 제안입니다. 이것은 height + border + margin + padding을 포함한다. –