function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
UvesUves 

Using JQuery to extract <apex:inputTextarea> Value

I am trying to use JQuery to extract value I have entered into my InputTextArea. I have tried few JQuery quotes and I always get the same error "undefined"

VisualForce Code
<div id="email" class="ff-form">
            <div class="ff-formtitle">Email</div>
            <div>
                <apex:pageBlock mode="view" id="pb">
                    <apex:pageBlockSection columns="1" id="pbs">
                        <apex:pageblocksectionitem >
                            <apex:outputLabel value="Email Body : " for="ebody"/>
                            <apex:inputTextarea id="eBody" value="{!emailbody}" rows="9" cols="50"  richText="true"/>
                        </apex:pageblocksectionitem>
                    </apex:pageBlockSection> 
                </apex:pageBlock>
            </div>
        </div>

JQuery Code
 
console.log(jQuery('input[id$="subject"]').val());
		console.log(jQuery('input[id$="eBody"]').val());
		console.log(jQuery('input[id$="eBody"]').html());
		console.log(jQuery('input[id$="eBody"]').text());
		console.log(jQuery('inputtextarea[name="eBody"]').val());
		console.log(jQuery('inputtextarea[name="eBody"]').html());
		console.log(jQuery('inputtextarea[name="eBody"]').text());
		console.log(jQuery('textarea[name="eBody"]').val());
		console.log(jQuery('textarea[name="eBody"]').html());
		console.log(jQuery('textarea[name="eBody"]').text());

I have tried all the above JQuery Syntax but unfortunatly it doesn't return the value I enter into my inputTextArea.
Any help would be appertiated. 
Thanks
 
Best Answer chosen by Uves
pconpcon
Because you are using the richText="true" flag, you have to do a bit more work.  This generates an HTML document in an iframe that you have to dig through.  This should get you what you want, but keep in mind that some browsers may not like this because of XSS restrictions.
 
jQuery('div[id$="eBody"] div div.cke_contents iframe').contents().find('body').html();

All Answers

pconpcon
Because you are using the richText="true" flag, you have to do a bit more work.  This generates an HTML document in an iframe that you have to dig through.  This should get you what you want, but keep in mind that some browsers may not like this because of XSS restrictions.
 
jQuery('div[id$="eBody"] div div.cke_contents iframe').contents().find('body').html();
This was selected as the best answer
Javier Freire GarcíaJavier Freire García

It's better to do this:

Object.values(CKEDITOR.instances)[0].setData(htmlBody);