html input image 尺寸,HTML Input Image width用法及代码示例

HTML DOM中的Input Image width属性用于返回的width属性的值。

用法:

要返回width属性。imageObject.width

设置width属性。imageObject.width = value;

属性值:它包含一个数值,以像素为单位指定图像的宽度。

返回值:它返回一个代表图像宽度的数值。

范例1:本示例返回输入图像宽度属性。

/p>

HTML DOM Input Image width Property

GeeksforGeeks

DOM Input Image width Property

type="image" src=

"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"

alt="Submit"

formaction="#"

formtarget="#"

formenctype="text/plain"

width="48"

height="48">

function my_geek() {

// Return formTarget, formEnctype and formAction.

var txt = document.getElementById(

"myImage").width;

document.getElementById(

"Geek_h").innerHTML = txt;

}

输出:

在单击按钮之前:

ab9cae1b97ed8a545591d6de917fa579.png

单击按钮后:

699782fd9b2efd80ec9e59e29b81af07.png

范例2:本示例设置“输入图像宽度”属性。

HTML DOM Input Image width Property

GeeksforGeeks

DOM Input Image width Property

type="image" src=

"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"

alt="Submit"

formaction="#"

formtarget="#"

formenctype="text/plain"

width="48"

height="48">

function my_geek() {

// Return formTarget, formEnctype and formAction.

var txt = document.getElementById(

"myImage").width = "96";

document.getElementById(

"Geek_h").innerHTML = txt;

}

输出:

在单击按钮之前:

ab9cae1b97ed8a545591d6de917fa579.png

单击按钮后:

dc38c8158389fd42a81adbaf06dfd268.png

支持的浏览器:下面列出了HTML DOM输入图像宽度属性支持的浏览器:

谷歌浏览器

IE浏览器

Firefox

Opera

Safari

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值