Get the value of tinymce4.x by JS

Source: Internet
Author: User

The problem arises:

In the use of the process, using the traditional JS method to judge TinyMCE selected textarea (hereinafter referred to as TEXTAREA) the value of this problem will occur:

In the existing input, the first time the submission, will still pop up the JS write warning prompt, and then submit to be successful.

When I learned that JS could not get textarea value directly, we looked around for solutions.

With the help of Bo friend Nkxyf, this problem has been solved.

Looking at the official documents for a long while, because English is not good, and is affected by other HTML text editor, I thought TinyMCE's documents will be in installation this piece will give the method of getting HTML content, but unfortunately I found a day. I can't find them either.

Fortunately, Baidu found Nkxyf bo Friends of a blog post: http://www.cnblogs.com/nkxyf/p/3883586.html

Ask him to fix the problem! Because the blog post is issued in July, I thought my message will be a long time to have a reply, but soon, the mailbox reminds me that Nkxyf quickly replied to my question. It was a surprise! At the same time also feel the blog Park mailbox alert function is really convenient!

All right, no more talking nonsense. Go to the Chase

tinymce4.x version js the correct way to get the value of textarea: var content = tinymce.get (' elm1 '). GetContent (); Note: ELM1 is the ID value of textarea, do not add #. TINYMCE can be used, or can be used TINYMCE

method on the official website of this document: Http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.getContent

// get the HTML contents of the currently active editor (gets the HTML content of the currently active editor) Console.debug (TinyMCE.activeEditor.getContent ()); // get the raw contents of the currently active editor (gets the native content of the currently active editors)TinyMCE.activeEditor.getContent ({ Format: ' Raw '}); // get content of a specific editor: (Get the contents of the specified editor, the above example is in this way) Tinymce.get (' Content ID '). getcontent ()

Something to think about the official documents first, but Baidu should first look at the document.

Get the value of tinymce4.x by JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.