(function($){
var props = ['Width', 'Height'],prop;
while (prop = props.pop()) {
(function (natural, prop) {
$.fn[natural] = (natural in new Image()) ? function () {return this[0][natural];} :
function () {
var node = this[0],img,value;
if (node.tagName.toLowerCase() === 'img') {
img = new Image();
img.src = node.src,
value = img[prop];
}
return value;
};
}('natural' + prop, prop.toLowerCase()));
}
}(jQuery))
var nWidth =`` $('#input_text>img').naturalWidth(),
nHeight = $('#input_text>img').naturalHeight();
**
获取图片原始宽高的方式
2016年4月25日view:2155
在文章任何区域双击击即可给文章添加【评注】!浮到评注点上可以查看详情。
评论
发表评论
暂无评论
PUBLISHED IN
本专栏其他文章
webpack和gulp的区别
时间:2017-03-09浏览:4987赞:0
js中this和$(this)的区别
时间:2017-03-08浏览:2739赞:0
微信摇一摇代码
时间:2016-04-11浏览:2871赞:0
js实现复制粘贴图片到输入框,
时间:2016-03-10浏览:6631赞:2
获取完整的参数,返回一个参数数组
时间:2015-12-25浏览:2371赞:0
获取参数值
时间:2015-12-25浏览:1797赞:0