如何使用jQuery清除ckeditor [英] how to clear ckeditor with jquery

查看:70
本文介绍了如何使用jQuery清除ckeditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单击按钮/链接时用jquery清除ckeditor文本区域?

How can i clear the ckeditor textarea with jquery at the click of a button/link?

我已经尝试过了:$("textarea.editor").val('');$("textarea.editor1").val('');我在PHP初始化编辑器$ckeditor->editor('editor1', $nDetails);时由于使用了这一行而在末尾尝试了1

I have tried this : $("textarea.editor").val(''); and $("textarea.editor1").val(''); i tried with the 1 at the end because of this line when init the editor $ckeditor->editor('editor1', $nDetails); in PHP

任何帮助将不胜感激.

<p>Details: 

    <?php

    // Helper function for this sample file.
    function printNotFound( $ver )
    {
        static $warned;

        if (!empty($warned))
            return;

        echo '<p><br><strong><span class="error">Error</span>: '.$ver.' not found</strong>. ' .
            'This sample assumes that '.$ver.' (not included with CKFinder) is installed in ' .
            'the "ckeditor" sibling folder of the CKFinder installation folder. If you have it installed in ' .
            'a different place, just edit this file, changing the wrong paths in the include ' .
            '(line 57) and the "basePath" values (line 70).</p>' ;
        $warned = true;
    }



    include_once '../ckeditor/ckeditor.php' ;
    require_once '../ckfinder/ckfinder.php' ;

    // This is a check for the CKEditor class. If not defined, the paths in lines 57 and 70 must be checked.
    if (!class_exists('CKEditor'))
    {
        printNotFound('CKEditor');
    }
    else
    {
        $initialValue = $pageContent;

        $ckeditor = new CKEditor( ) ;
        $ckeditor->basePath = '../ckeditor/' ;

        // Just call CKFinder::SetupCKEditor before calling editor(), replace() or replaceAll()
        // in CKEditor. The second parameter (optional), is the path for the
        // CKFinder installation (default = "/ckfinder/").
        CKFinder::SetupCKEditor( $ckeditor, '/ckfinder/' ) ;

        $ckeditor->editor('editor1', $nDetails);
    }

    ?></p>

推荐答案

CKEDITOR.instances.editor1.setData('');

editer1是CKEDITOR字段的ID

Where editor1 is the id of your CKEDITOR field

这篇关于如何使用jQuery清除ckeditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆