jquery中的图像原始宽度 [英] Image native width in jquery

查看:85
本文介绍了jquery中的图像原始宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery,我点击更改图像的src

With jQuery, i change the src of an image on click

$("#thumb li img").click(function() {
var newlinkimage = $(this).attr("src");

newlinkimage = newlinkimage.substring(14,17);

    $("#avant img").attr("src", 'retouche-hr' + newlinkimage + '-a.jpg');
    $("#apres img").attr("src", 'retouche-hr' +newlinkimage + '-b.jpg');

问题是,新图像宽度与旧图像宽度不同。我如何获得新图像的NATIVE宽度(如在Dreamweaver中获得该图像的小箭头

The problem is, that the NEW image width is different that the old. HOW do i get the NATIVE width of the new image (like the little arrow that get that in dreamweaver

推荐答案

这是一种简单的javascript方式。应该很容易将它集成到你的代码中。

This is the plain javascript way to do it. It should be easy to integrate this into your code.

var newimage = new Image();
newimage.src = 'retouche-hr' + newlinkimage + '-a.jpg'; // path to image
var width = newimage.width;
var height = newimage.height;

这篇关于jquery中的图像原始宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆