Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can I control CSS attributes with javascript?

    I saw an idea on another website and i wan't to incorporate it into mine.
    How can I use javascript to control the css "display" attribute and change it from "none" to "block" on a div

  • #2
    New Coder
    Join Date
    Aug 2003
    Location
    Rhondda Cynon Taff, Wales
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do you mean hidden?
    Ryan Jones(sciguyryan)
    Visit us and chat at our forums - the Kidscript Forums

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple example

    Code:
    <script>
    	function toggleDiv(div)
    	{
    		if(div.style.display == "none")
    			div.style.display = "block";
    		else
    			div.style.display = "none";
    	}
    </script>
    
    <body>
    
    <center>
    <table cellpadding="3" cellspacing="0" width="300" bgcolor="#cccccc" style="border: thin solid black">
    <tr>
    	<td style="cursor:hand;" onclick="toggleDiv(document.all.testdiv);">
    		<font face="arial">
    			To toggle div display, click on this row
    		</font>
    	</td>
    </tr>
    <tr>
    	<td bgcolor="#dbdbdb">
    		<div id="testdiv" name="testdiv" style="display:block;">
    			<font face="arial">
    				The divs content
    			</font>
    		</div>
    	</td>
    </tr>
    </table>
    </center>
    
    
    </body>
    Simple example for you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •