glenelkins Posted February 13, 2008 Share Posted February 13, 2008 Hi I can get the offsetTop value of an unordered list like so: var LI_Items = document.getElementsByTagName ( "li" ); for ( var i = 0; i < LI_Items.length; i++ ) { var this_offsetTop = LI_Items[i].offsetTop; } but how do i set the offsetTop ?? If i try LI_Items.offsetTop = 10 its produces an error Link to comment https://forums.phpfreaks.com/topic/90901-ul-list-item-setting-offsettop/ Share on other sites More sharing options...
phpQuestioner Posted February 13, 2008 Share Posted February 13, 2008 It's because your putting a variable in the for condition. Link to comment https://forums.phpfreaks.com/topic/90901-ul-list-item-setting-offsettop/#findComment-466293 Share on other sites More sharing options...
glenelkins Posted February 14, 2008 Author Share Posted February 14, 2008 how do you mean? I used that as an example of how I can get the objects offsetTop. All I need to know is how do i set the list item offsetTop to something different Link to comment https://forums.phpfreaks.com/topic/90901-ul-list-item-setting-offsettop/#findComment-466601 Share on other sites More sharing options...
phpQuestioner Posted February 14, 2008 Share Posted February 14, 2008 try this instead and see if it is what your wanting: <script language="javascript"> var LI_Items = document.getElementsByTagName("li"); for (i=0;i<LI_Items.length;i++) { LI_Items[i].style.marginTop="10"; } </script> Link to comment https://forums.phpfreaks.com/topic/90901-ul-list-item-setting-offsettop/#findComment-466628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.