javascript highlight
<p>i try to make the div color changed when click or focus on textbox so i do this js function but it change the textbox color not its div</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;title&gt;test&lt;/title&gt;
    &lt;style type="text/css"&gt;
    /* This is the CSS class to use when no focus is on the input control */
    .input_text
    {
        border:1px solid #c0c0c0;
        padding:4px;
        font-size:14px;
        color:#000000;
        background-color:#ffffff;
    }
    /* This is the CSS class to use when the control has focus */
    .input_text:focus, input.input_text_focus
    {
        border-color:#646464;
        background-color:#ffffc0;
    }
    &lt;/style&gt;
    &lt;script type="text/javascript"&gt;
    // creates a function to set the css class name of input controls when they
    // receive or lose focus.
    setAspnetTextFocus = function() {
        // CSS class name to use when no focus is on the input control
        var classBlur = 'input_text';
        // CSS class name to use when the input control has focus
        var classFocus = 'input_text_focus';
        // get all of the input tags on the page
        var inputElements = document.getElementsByTagName('input');

        for (var i = 0; i &lt; inputElements.length; i++) {
            inputElements[i].onfocus = function() {
                if (this.className == 'input_text') {
                    this.className += ' ' + classFocus;
                }
            }
            // add the onblur event and set it to remove the on focused CSS class when it loses focus
            inputElements[i].onblur = function() {
                this.className = this.className.replace(new RegExp(' ' + classFocus + '\\b'), '');
            }
        }
    }
    // attach this event on load of the page
    if (window.attachEvent) window.attachEvent('onload', setAspnetTextFocus);
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="input_text" &gt;
&lt;input type="text" id="TextBox1" class="input_text" /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>any ideas?</p>
