Stemboy4002
Stemboy4002

Reputation: 67

how to set image width to clientHeight x 5.128571428571429

I have a script where I need to set the width of an img tag to the clientHeight of the img tag.

This is my code:

var logo = document.getElementById("logoImg");
logo.width = logo.clientHeight * 5.128571428571429 + "px";

If the clientHeight of the img tag is 70px, then the width of it should by set to 359px, how could I this.

Upvotes: 0

Views: 31

Answers (1)

johnheroy
johnheroy

Reputation: 416

Width should be set to a number, not a string. Try this instead:

logo.width = logo.clientHeight * 5.128571428571429;

Upvotes: 2

Related Questions