0

I want to create image using HTML5, With HTML5 I can set any property of image.

var img = new Image()
img.id="image1"
img.name
img.src="image1.jpg"
img.style="-webkit-transform: rotate(90deg)"

the result will become

<img src="image1.jpg" id="image" name="asdasd">

all will work except style because I hope the result will be

<img src="image1.jpg" id="image" name="asdasd" style="-webkit-transform: rotate(90deg);">

please help me, thx

3

2 Answers 2

3

I think it should be:

img.style['-webkit-transform'] = 'rotate(90deg)';

(see this page)

2

You can set the cssText field like so

var img = new Image()
img.id="image1"
img.src="image1.jpg"

img.style.cssText = '-webkit-transform: rotate(90deg)'

Then when you evaluate the markup for the element, it will display

<img id="image1" src="image1.jpg" style="-webkit-transform: rotate(90deg);">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.