kindeditor获取内容,清空,设置kindeditor输入提示信息

本文介绍如何使用KindEditor富文本编辑器进行初始化配置,并实现默认提示信息的显示与清除功能。具体包括设置编辑器的基本属性、监听焦点事件以移除默认文字提示,以及通过点击事件来清除这些默认信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1初始化kindeditor

var clearDefault=true;//是否有默认文字信息
var editor = KindEditor.create('textarea[name="s_content"]', {
	allowFileManager : true,
	filterMode:true,
	width : '100%',
	height:'291px',
	items:items_simp,
	afterFocus : function(){//获得焦点 删除默认文字信息
		editor.sync('#s_content');
		if(clearDefault){	
		 if(document.getElementById('s_content').value=="<span style=\"color:#999999;\">企业简介(不少于</span><span style=\"color:#999999;\">600</span><span style=\"color:#999999;\">字)、图片(不少于一张、 图片宽不得大于</span><span style=\"color:#999999;\">800px</span><span style=\"color:#999999;\">,高不限)、宣传视频可根据企业情况选择上传。</span>"){
			KindEditor.html("#s_content","");
	     } 
			clearDefault=false;	
		}
	},
	afterBlur: function(){this.sync();}//失去焦点,同步信息数据
	uploadJson : '<%=basePath%>/r/plugins/kindeditor/jsp/upload_json.jsp',
    fileManagerJson : '<%=basePath%>/r/plugins/kindeditor/jsp/file_manager_json.jsp'
});

2点击清除默认信息

点击清除默认信息
//同步kindeditor至<textarea>内
editor.sync('#s_content');
//清空kindeditor内容
KindEditor.html("#s_content","");
//初始为true 首次点击清除kindeditor内容后 变为false
clearDefault=false
//获取文本内容使用原生js
document.getElementById('s_content').value


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值