#116 √ invalid
Julien Garand

Element.setStyle() not working as expected

Reported by Julien Garand | May 21st, 2008 @ 12:08 PM

Hi,

The following code doesn't work as expected :

var style = {};
style.width   = 12;
style.height = 34;
style.top      = 56;
style.left      = 78;
$('whatever').setStyle( style );

Why ? Cause styles cannot be integers, but have to be strings !!!

Instead, I should have written :

var style = {};
style.width   = 12 + 'px';
style.height = 34 + 'px';
style.top      = 56 + 'px';
style.left      = 78 + 'px';
$('whatever').setStyle( style );

It could be great that int would be understood as a pixel length...

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Tags