尝试使用这段代码:
$('your-image').css({
width: '',
height: ''
});
如果您想设置“原始”图像尺寸,请尝试以下方法:
$('your-image').css({
width: 'auto',
height: 'auto'
});
$('your-image')
.removeAttr("width").removeAttr("height")
.css({ width: "", height: "" });
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function($){
$('img').each(function(){
$(this).removeAttr('width')
$(this).removeAttr('height');
});
});
</script>
let articleContentImages = document.getElementById("articleContent").getElementsByTagName("img");
for(let i = 0; i < articleContentImages.length; i++){
articleContentImages[i].style.height = "auto";
articleContentImages[i].style.width = "auto";
}
$('img').width('auto').height('auto');
继承可能是其中一种方式。
$('your-image').css({ width: "inherit", height: "inherit" });