在以下情况下,如何设置图像的宽度

How to set the width of the image in the following case?

本文关键字:设置 图像 情况下 何设置      更新时间:2023-09-26

我有一个图像,我想在其中用javascript设置宽度。

它是用以下格式写的,我如何设置宽度?

create("td",{colspan:"4",innerHTML:"<img src='"  + imagePath +  "Images/categoriesLogos.jpg'> style= 'width:900px'"},"space1");

此处imgePath是一个变量。它会拾取图像,但如何分配宽度?

尝试使用代码中显示的样式。

内联style标记在img标记之外。

试试这个:

create("td",{colspan:"4",innerHTML:"<img src='"  + imagePath +  "Images/categoriesLogos.jpg' style= 'width:900px'>"},"space1");

如果您想将其设置为内联,您的样式属性应该在元素内部,在结束标记>之前。