제이쿼리 이미지 사이즈 구하기 채택완료
아래 예제로 하면 업로드된 업로드 이미지 사이즈가 나오더라고요
저는 화면에 보이는 리사이징된 값을 구하고 싶은데 방법이 없을까요?
Copy
var img = $("#map"); // Get my img elem
var pic_real_width, pic_real_height;
$("") // Make in memory copy of image to avoid css issues
.attr("src", $(img).attr("src"))
.load(function() {
pic_real_width = this.width ; // Note: $(this).width() will not
pic_real_height = this.height ; // work for in memory images.
alert( '' + pic_real_width + ',' + pic_real_height )
});
답변 1개
채택된 답변
+20 포인트
선택과집중
1년 전
var rect = img.getBoundingClientRect();
// 화면에 보이는 사각형 정보를 가져옴
rect.width
rect.height
를 확인하면 될거에요
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인