专注于CKEditor删除默认值 [英] CKEditor on focus remove default value

查看:61
本文介绍了专注于CKEditor删除默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于普通输入字段,我可以编写类似以下代码的内容,该代码将在我单击时删除输入字段的默认值,如果我在输入字段中不写任何内容,则默认值将在我返回时返回离开输入字段。

  jQuery('input [type = text]')。focus(function()
{
if(this.value == this.defaultValue)
{
this.value ='';
}
if(this.value!= this.defaultValue)
{
this.select();
}
});

jQuery('input [type = text]')。blur(function()
{
if(this.value =='')
{
this.value = this.defaultValue;
}
});

但是我不知道如何使用CKEditor做到这一点。 p>

我找到了此代码,当我单击CKEditor时它将发出警报。但是我不知道如何修改它以符合我需要的方式。

  CKEDITOR.instances ['post_content']。on(' focus',function()
{
alert(1);
});


解决方案

您尝试过吗?

  CKEDITOR.instances ['post_content']。on('focus',function()
{
if(this.value == defaultValue)
{
this.value ='';
}
});


For a normal input field i can write something like the below code, which will remove the default value of an input field when i click, and if i dont write anything in the input field, than the default value will return when i leave the input field.

jQuery('input[type="text"]').focus(function()
    {
        if (this.value == this.defaultValue)
        {
            this.value = '';
        }
        if(this.value != this.defaultValue)
        {
            this.select();
        }
    });

    jQuery('input[type="text"]').blur(function()
    {
        if (this.value == '')
        {
            this.value = this.defaultValue;
        }
    });

But i have no clue how to do this with CKEditor.. Can I get some help.

I found this code which will alert when I click in the CKEditor. But I dont know how modify it to work the way I need.

CKEDITOR.instances['post_content'].on('focus', function()
{
    alert(1);
});

解决方案

Have you tried this?

CKEDITOR.instances['post_content'].on('focus', function()
{
    if (this.value == defaultValue)
    {
        this.value = '';
    }
});

这篇关于专注于CKEditor删除默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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