On the site created by WordPress, we have created a feature that allows you to zoom in and out of images by manipulating css left, top, transform:scale in jQuery/JavaScript.
In addition, I would like to get the above value, but the value is reflected in element.style and the acquisition is not successful.
Could you tell me how to get this "element.style" value?
Additional
As you advised me, I tried the following two patterns, but I got both errors.
I would appreciate it if you could point out what the problem is.
$(function(){
$("#ss").on("click", function(){
// varimg_css = document.querySelector("#preveiw_card_image_innerimg").style;
varimg_css=$("#preveiw_card_image_inner img");
varcssvalue=getComputedStyle(img_css[0], "");
// alert(img_css);
alert(cssvalue);
});
});
img_css
is the jQuery object and getComputedStyle()
must be an Element.
var cssvalue=getComputedStyle(img_css[0], "");
I personally don't think beginners should use jQuery because using jQuery increases the number of problems and things that need to be remembered.
In this case, you can also access the style
property of the Element object without using getComputedStyle()
.
document.querySelector('#preview_card_image_innerimg').style
© 2024 OneMinuteCode. All rights reserved.