Issue with the document.getElementById('editor') in JQuery

Issue with the document.getElementById('editor') in JQuery

All,

I have a JQuery script as follow:

<script>
   
     $(document).ready(function() {
        
         var buttonSelected = '${docEditorReviewCaseData.buttonSelected}';
         console.log(buttonSelected);
         
         if(buttonSelected == 'Save'){
           
            console.log(document.getElementById('editor'));
            document.getElementById('editor').SaveURL('${docEditorReviewCaseData.saveReviewCaseXMLURL}');
     }
     });
</script>

When I run this jsp page in IE 8 with developer tools and debugger I get an error and the value is 0 for the element.

      Object reference not set to an instance of an object.



When I run the same command thru a javascript I do not get the error and it runs fine.

<script>
      function saveFunction(){
                document.getElementById("editor").SaveURL("${docEditorReviewCaseData.saveReviewCaseXMLURL}");
      }
</script>


Any Idea what am I missing or doing wrong?  By the way, I did try to run the same command with double quotes too.  Just in case someone asks