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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.