Pritam Banerjee
Pritam Banerjee

Reputation: 18923

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

I have an image, where I want to set the width in javascript.

It is written in the following format, how do I set the width?

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

Here imgePath is a variable. It picks up the image, but how do I assign the width?

Tried to use style the way it is shown in the code.

Upvotes: 2

Views: 73

Answers (2)

Ciprianis
Ciprianis

Reputation: 255

If you want to set it inline, your style attribute should be inside the element, before the closing tag >.

Upvotes: 1

AndrewL64
AndrewL64

Reputation: 16301

The inline style tag is outside of your img tag.

Try this:

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

Upvotes: 3

Related Questions