#116 ✓invalid
Julien Garand

Element.setStyle() not working as expected

Reported by Julien Garand | May 21st, 2008 @ 12:10 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 Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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

Pages