Jump to content

Accessing stylesheet using getElementById


djamidin

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...