Link to home
Start Free TrialLog in
Avatar of mousemat24
mousemat24

asked on

Use a different CSS class on the fly

Hi there

Wonder if you can help me, with a simple CSS/Javascript/HTML issue I have

I have this HTML:

<style>
.book
{
  color: black;
  font-size:10pt;
}

.book2
{
  color: red;
  font-size:10pt;
}
</style>

<table>
  <tr>
    <td class="book">
      Book1
    </td>
  <tr>
  <tr>
    <td class="book">
      Book2
    </td>
  <tr>
  <tr>
    <td class="book">
      Book3
    </td>
  <tr>
  <tr>
    <td class="book">
      Book4
    </td>
  <tr>
</table>

How can I change (swap) from class="book" to use class="book2" on the fly? i.e. using JavaScript


Thanks
Avatar of jello024
jello024

document.getElementById("objectID").className = "newClassname";
ASKER CERTIFIED SOLUTION
Avatar of jello024
jello024

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mousemat24

ASKER

thanks jello024!!