title: How to change font-weight of a text using JavaScript
body: <p>I have a button that looks like this:</p>
  <p>HTML:</p>
  <pre><code>&lt;button type=&quot;button&quot; id=&quot;top_skin&quot; onclick=&quot;theme()&quot;&gt;Theme: &lt;span id=&quot;dark&quot;&gt;Dark&lt;/span&gt;/&lt;span id=&quot;light&quot;&gt;Light&lt;/span&gt;&lt;/button&gt;
  </code></pre>
  <p>CSS:</p>
  <pre><code>#top_skin{display:inline;
  float:right;
  margin:5px 15px 5px 5px;
  padding: 0px 5px 0px 5px;
  height:20px;
  min-width:140px;
  background:grey;
  cursor:pointer;
  border-radius:5px;
  overflow:hidden;
  }
  
  #dark{font-weight:bold;}
  </code></pre>
  <p>I want JavaScript to switch the font-weight of the words &quot;Dark&quot; and &quot;Light&quot; so that when I click the button the word &quot;Light&quot; gets bold and &quot;Dark&quot; gets normal. And when I click again I want &quot;Dark&quot; to be bold and &quot;Light&quot; to be normal. But I can't make it work. The funny thing is that I can create a function that do the same thing, but with color in stead of font-weight.</p>
  <p>The code that works but changes color instead of font-weight:</p>
  <pre><code>function theme(){
  var dark = document.getElementById('dark');
  var light = document.getElementById('light');
  
  if(light.style.color !== &quot;red&quot;){
      light.style.color=&quot;red&quot;;
      dark.style.color=&quot;black&quot;;
  }else{
      dark.style.color=&quot;red&quot;;
      light.style.color=&quot;black&quot;;
  }}
  </code></pre>
  <p>The code that I thought would do the same thing, but with font-weight:</p>
  <pre><code>function theme(){
  var dark = document.getElementById('dark');
  var light = document.getElementById('light');
  
  if(light.style.fontWeight !== &quot;bold&quot;){
      light.style.fontWeight=&quot;bold&quot;;
      dark.style.fontWeight=&quot;normal&quot;;
  }else{
      dark.style.fontWeight=&quot;bold&quot;;
      light.style.fontWeight=&quot;normal&quot;;
  }}
  </code></pre>
  <p>Thank you!</p>
  <h3>Edit:</h3>
  <p>Now this time when I try it it seems to work just fine for me too. I suppose there have been a typo somewhere.
  Thank you all for your answers, and I am sorry I took your time!</p>