I am basically searching for a function that can be invoked on onClick event of a button. Also when saving the content it should be clear that which text area's content need to be saved if multiple text editors are present on the same page.
It depends how you have implemented the multiple text editors using CodeMirror. The following code returns the content of the editor instance.
editor.getValue();
Use this to save the content of a particular CodeMirror instance.