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 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:

...I finally hand typed the identical code into another jsfiddle window... 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.
Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
The second one is missing a ')' after 'checked'...

if (document.getElementById('yesCheck').checked) <<<<<<<
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.