Search code examples
javascriptphpjquerycssckeditor

How to hide CKEditor


I have two CKEditor in same page. How can I hide one of them?

I tried to change textarea display and visibility to hidden but it does not work.

$("textarea[name=icerik]").css("visibility", "hidden");
$("textarea[name=enicerik]").css("visibility", "visible");

Here are the initial CKEditors:

  CKEDITOR.replace( 'icerik' );
  CKEDITOR.replace( 'enicerik' );

Solution

  • It sounds like you are not getting the correct element from the jQuery you provided in:

    $("textarea[name=icerik]")
    

    Right click on your CKEditor you don't want and click on 'Inspect Element'. In the console, look for the top div of the CKEditor and find its id or its name. If you find the id of it you will be able to call:

    $('#ckeditor-id').hide();
    

    You will need to provide more details about your problem if there is no id for the CKEditor. It would be easier to diagnose the problem if you provided some code from your project or the html that is generated from the code.

    TIP: You can also use the 'console' tab after you click 'inspect element' to view any javascript/jQuery errors you are having. If indeed you are not getting the correct element from the jQuery you provided, an error will show up in the console.

    EDIT

    Try calling this inside the on load callback for CKEditor, not the document:

    CKEDITOR.on("instanceReady", function(event)
    {
         //put your code here
    });