Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript to find TinyMCE rich text editor value is null or not

I use the TinyMCE textarea in one of my web applications.

  1. How to check the TinyMCE textarea's value is null or not using JavaScript?

document.getElementById("myeditorid").value didn't help me.

like image 328
ACP Avatar asked Jan 23 '10 04:01

ACP


People also ask

How do I get TinyMCE editor value?

The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.

What is rich text in JavaScript?

Rich Text is a field type that enables authors to create rich text content, similar to traditional "What you see is what you get" (wysiwyg) editors. The key difference here is that the Contentful Rich Text Field (RTF) response is returned as pure JSON rather than HTML.

What is TinyMCE JavaScript?

TinyMCE is an online rich-text editor released as open-source software under the MIT License. It has the ability to convert HTML text area fields or other HTML elements to editor instances. TinyMCE is designed to easily integrate with JavaScript libraries such as React, Vue.


2 Answers

It's not a textarea any more, so the value property won't work.

This is how you get a reference to the editor, and the text from it:

var text = tinyMCE.get('myeditorid').getContent();
like image 195
Guffa Avatar answered Sep 21 '22 04:09

Guffa


var text = tinyMCE.get('createSurvey:thankyouMsg_ifr').getContent();

here the predefined id was "thankyouMsg"..After the tinyMCe,its id changed to this.I try to get the value in this way but it is not working saying tinyMCE.get('createSurvey:thankyouMsg_ifr') is undefined

like image 38
Abhishek Avatar answered Sep 22 '22 04:09

Abhishek