Javascript Dont Change The Background : <p>I want to change my list background but it wont work</p>

<p>my code :</p>

<pre><code>change(num, element){
var text

if (num == 1){ ... }
else if (num == 2) { ... }
else { ... }

document.getElementById('text').innerHTML = text;

document.getElementByClass("left").style.backgroundColor = "black"; //&lt;------ 
element.style.backgroundColor = "white";                            //&lt;------
}
</code></pre>

<p>and my html :</p>

<pre><code>&lt;ul&gt;
   &lt;li&gt;&lt;a class="left" href="#" onclick="change(1,this)&gt;First&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a class="left" href="#" onclick="change(2,this)&gt;Second&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a class="left" href="#" onclick="change(3,this)&gt;Third&lt;/a&gt;&lt;/li&gt;      
&lt;/ul&gt;
</code></pre>

<p>When i click on one of my list element , the text changes but background color won't ...</p>

<p>How i can fix this ?</p>

<p>Thanks,</p>
