의 scrollHeight를 가져옵니다 :이 코드와 사업부의 scrollHeight를 얻으려고 노력 오전 DIV
GQuery element = $(".pre.line-numbers");
String height = element.attr("scrollHeight");
Window.alert(height); // empty!
$("pre.line-numbers")
.css("overflow-y", "hidden")
.css("overflow-x", "auto")
.css(CSS.HEIGHT, height + "px"); // here
을하지만 매번, 문자열의 높이가 빈 문자열입니다.
브라우저 검사기로 두 번 확인했는데 높이가 있습니다. 또한이를 확인하기 위해 수동으로 높이를 특정 값으로 설정했으며 해당 값이 pre.line-numbers
div에 적용되었음을 알 수 있습니다.
여기에 무엇이 누락 되었습니까? 모든 주요 브라우저 (Firefox 및 Chrome)에 대해 scrollHeight를 가져 오는 올바른 방법은 무엇입니까?
아마 도움이 :'scrollHeight'는 속성이 아닌 속성이며, 정수가 아닌 문자열. –
여기에 이미 답변되었습니다 : http://stackoverflow.com/questions/25609506/jquery-height-outputting-same-value-as-scrollheight-on-div-with-overflowaut –