ckeditor字數限制


var maxlength = 200;
   _editor=CKEDITOR.replace("ckeditor",{height:'130px'});
   _editor.on('key',function(event){
		var oldhtml = _editor.document.getBody().getHtml();
		var description = oldhtml.replace(/<.*?>/ig,"");
		var etop = $("#cke_1_top");
		var _slen = maxlength-description.length;
		var canwrite = $("<label id='canwrite'>還可以輸入200字</label>");
		if(etop.find("#canwrite").length<1){
			canwrite.css({border:'1px #f1f1f1 solid','line-height':'28px',color:'#999'});
			etop.prepend(canwrite);
		}
		var _label = etop.find("#canwrite");
		if(description.length>maxlength){
			//alert("最多可以輸入"+maxlength+"個文字,您已達到最大字數限制");
			_editor.setData(oldhtml);
			_label.html("還可以輸入0字");
		}else{
			_label.html("還可以輸入"+_slen+"字");
		}
	});

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM