gpt4 book ai didi

jquery - 有没有办法用jquery读出图像的 "naturalWidth"?

转载 作者:行者123 更新时间:2023-12-03 21:49:39 25 4
gpt4 key购买 nike

我尝试过这样的事情:

var Height = $(this).naturalHeight;

但是这不起作用。有没有办法做到这一点

格瑞兹

最佳答案

我在应用 jQuery 然后剥离 jQuery 后使用 native javascript 属性

.naturalWidth / .naturalHeight

在我使用的 jQuery 对象上

var width = this.naturalWidth; 
var height = this.naturalHeight;

var width = $("selector").get(0).naturalWidth; 
var height = $("selector").get(0).naturalHeight;

如果没有选择 jQuery 对象。

With get(0) on a jQuery object you can access the associated DOM-element 。在 native DOM 元素上,您可以使用 native javascript 代码(此处访问 native javascript 属性 .naturalWidth)

关于jquery - 有没有办法用jquery读出图像的 "naturalWidth"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1832907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com