使用jquery更改图像尺寸 [英] change image dimensions with jquery

查看:135
本文介绍了使用jquery更改图像尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div id myimage下有一张图片。现在我想通过改变来调整它的大小。我想从选择框700X7000选择框,然后图像的尺寸将是高700px和宽700px。没有重新加载页面。
任何人都可以帮我,我该怎么做?

I have a image under div id myimage. Now I want to resize it by using change. I want from select box if selected 700X7000 then image's size will be height 700px and width 700px. With out reloading the page. Can anyone help me how can I do this?

推荐答案

好吧,要改变它,你可以设置图像的 width() height()

Well, to change it, you can just set the image's width() and height():

$('#myimage').width(700); // Units are assumed to be pixels
$('#myimage').height(700);

因此,您可以将下拉框设置为 100x100 200x200 等,拆分所选值为提取尺寸:

So for you to do the drop down box, you can just set the values to be something like 100x100, 200x200, etc. and split the selected value to extract the dimensions:

var parts = '100x100'.split('x');
var width = parseInt(parts[0], 10); // 10 forces parseInt to use base 10
var height = parseInt(parts[1], 10);

这篇关于使用jquery更改图像尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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