Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you use Javascript to change Style properties

Status
Not open for further replies.

econnections

IS-IT--Management
Apr 28, 2006
30
GB
In the simple example shown below I want to be able hide column3 by calling a function that changes the properties of style1 from .style1 {display:block;} to .style1 {display:none;}. Is this possible?

Any help would be appreciated.

<style>
.style1 {display:block;}
</style>

<table>
<tr>
<td>Column1</d>
<td class="style1">Column2</td>
<td>Column3</d>
<tr>
<tr>
<td>Column1</d>
<td class="style1">Column2</td>
<td>Column3</d>
<tr>
<tr>
<td>Column1</d>
<td class="style1">Column2</td>
<td>Column3</d>
<tr>
</table>
 
This is what I would try:

Code:
<script ...>

function ChangeClass(object) {

document.getElementById(object).className=style2;

}

</script>

Give your columns an ID (i.e: id="column1") and set your trigger to pass the ID you wish to affect

onClick="ChangeClass('column1'); return true;"


Hope this helps.


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top