如何去除高度和宽度?

raj*_*hrt 11 javascript css jquery

目前我正在使用jquery处理图像滑块.我已经从网上下载了代码.我的代码演示就在这里.

我的问题是:如何将图像标签动态附加的高度和宽度删除为内联样式?

谢谢.

Ole*_*gas 13

尝试使用此代码:

$('your-image').css({ 
  width: '',
  height: ''
});
Run Code Online (Sandbox Code Playgroud)

如果要设置"原始"图像尺寸,请尝试以下操作:

$('your-image').css({ 
  width: 'auto',
  height: 'auto'
});
Run Code Online (Sandbox Code Playgroud)


Ari*_*tos 11

要使其从各方面工作,您需要删除属性和CSS.这是我的代码的工作.

$('your-image')
   .removeAttr("width").removeAttr("height")
   .css({ width: "", height: "" });
Run Code Online (Sandbox Code Playgroud)