Q:

Joomla editor post content via JQuery

I trying to create my component which include Joomla CodeMirror plugin.
I filled textarea with my text and now I want to get that text from JQuery for send to another place.
    jQuery("#button").click(function(event){
        jQuery('#spinner').show();
        var code = jQuery('#texteditorarea').html();

        jQuery.post("index.php?option=com_one&view=One&format=raw",
        {
            source:code
        },
        function(data) {
            jQuery('#spinner').hide();
            jQuery("#result").hide().html(data).fadeIn('slow');
        });
    });

Here I have a problem when I changed text in Joomla editor field (on my page). When I click on my button after change, in this code I do not see any changes. 
With
var code = jQuery('#texteditorarea').html();

I always get initial text.
How can I catch current text in Joomla editor text filed?

A:

I have found answer
Instead:
var code = jQuery('#texteditorarea').html();

Use:
var code = Joomla.editors.instances['texteditorarea'].getCode();

