djamidin Posted November 25, 2005 Share Posted November 25, 2005 Hello,I am trying to alter the float property in a stylesheet on a onclick() event. function EventCollapse(){ if(dd==0) { dd=1; document.getElementById('hideevents').style.visibility="hidden"; document.getElementById('hideevents').style.width="0px"; document.getElementById('collapseB').style.float="right"; } else { dd=0; document.getElementById('hideevents').style.visibility="visible"; document.getElementById('hideevents').style.width="222px"; document.getElementById('collapseB').style.float="left"; }} the visibility works.width i am not sure not checked butthe float property is foolhardy.Is there a reason for this or is there another way to do this??? Link to comment Share on other sites More sharing options...
djamidin Posted November 28, 2005 Author Share Posted November 28, 2005 In other words,How can i change the float property of an element using Javascripting,Thank you! Link to comment Share on other sites More sharing options...
djamidin Posted November 28, 2005 Author Share Posted November 28, 2005 solution thanks to hacknsack.using position absolute and the left property!not exactly a way to influence the float property but a way around it.Thx Link to comment Share on other sites More sharing options...
hacknsack Posted November 28, 2005 Share Posted November 28, 2005 Thanks for letting us know that you got it worked out.Here's an example of what was proposed: <html><head> <title></title><style type="text/css">#A{ position: absolute; visibility: hidden; background-color: #80FFFF; } </style><script type="text/javascript">var sDiv = true;function toggle(){var oDiv = document.getElementById('A'); if(sDiv){ sDiv = false; oDiv.style.top = 15 oDiv.style.left = 60; oDiv.style.visibility = 'visible'; } else{ sDiv = true; oDiv.style.visibility = 'hidden'; }}</script></head><body><div>This is some test test. This is more test text.<br>This is some test test. This is more test text.<br>This is some test test. This is more test text.<br></div> <div id="A"> This is a div to toggle.<br> This is a div to toggle.<br> This is a div to toggle.<br> </div> <a href="javascript:toggle()">Toggle Div</a></body></html> Thanks, Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now