tags:

views:

42

answers:

2
+2  Q: 

jquery issue on IE

Hello, here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click function on radio.

It works on Firefox,but it only works on IE when you click any where on page. Why IE does not render elements in real time like firefox. Please advise.

Thanks here is the code:

<script type="text/javascript"> 
function toggleStatus() {
    if ($('#toggleElement').is(':checked')) {
        $('#elementsToOperateOn :input').attr('disabled', true);
    } else {
        $('#elementsToOperateOn :input').removeAttr('disabled');
    }   
}
</script>


    Click to change: <input id="toggleElement" type="checkbox" name="toggle" onchange="toggleStatus()" />
    </p>
    <div id="elementsToOperateOn">
        This is our example div block. <br />
        Sample Text Box: <input type="text" name="name" /> <br />
        Sample Checkbox : <input type="checkbox" name="participate" /> <br/>
        Sample Radio : <input type="radio" name="bookEarly" /> <br />
        Sample Select: <select name="sampleSelect">
                            <option>Option 1</option>
                            <option>Option 2</option>
                        </select>
    </div>
+2  A: 

My guess is that IE doesn't fire the onchange event until after the radio element loses focus. You could use the onclick event instead.

Gabriel Hurley
+1 this is why we use onclick for checkbox/radio instead.
bobince
A: 

Yes you are right, it should have been $(el).click() function. This example was using $(el).change() function. Thanks for you help!!

leo