简体   繁体   中英

setStyle in Prototype doesn't appear to be functioning as intended?

http://i44.tinypic.com/b69h1h.jpg

Take a look at the above image, especially the Firebug window.

Now have a look here:

http://i40.tinypic.com/v2z4up.jpg

Has anyone noticed that my JS isn't working? This code was working when I wrote it and let it sit individually, but now that I've integrated it into a site, it appears that the vote box does not change the location as desired.

The CSS measures are always expressed with a unit : you need to add "px" to the left and top CSS attributes.

element.setStyle({left: 2+'px', top: 2+'px'});

I think you need to show the elements, as setting a position to a hidden element is not really useful.

element.show().setStyle({left: 2+'px', top: 2+'px'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM