Link to home
Start Free TrialLog in
Avatar of Petrusvb
Petrusvb

asked on

JavaScript 'visibility' or 'display' - works in one copy not in identical copy

Dear Colleagues:

                            I have some javascript which is based on using the 'display' or the 'visibility' properties - either one is fine.  

The line of code that needs to either display or be hidden reads:

<span id="ifyes" style="display:none">  Blah, blah, blah...</span>

...this line using either 'display' or 'visibility' works fine - with the style in place it vanishes.

However, when one adds this javascript

...it works in some scripts and not in others.

<script type="text/javascript">
    function yesnoCheck() {
        if (document.getElementById('yesCheck').checked) {
            document.getElementById('ifYes').style.display = 'block';
        } else document.getElementById('ifYes').style.display = 'none';

    }

...that works and can be seen working as a jsfiddle at:

http://jsfiddle.net/QAaHP/50/

...I finally hand typed the identical code into another jsfiddle window...

http://jsfiddle.net/Qqj5R/52/

...it DOES NOT work, and yet it appears identical.  Running in a different browser and/or on a different O/S makes no difference (checked just in case...).

I need this functionality working in my own production code and I can not get it to work - can anyone tell me why the one script works and the other does not?  If I know why in these examples I can fix my own similar code.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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