【发布时间】:2017-03-25 04:05:46
【问题描述】:
我限制了可以添加为特殊页面(活动提交页面)内容的字符数。它在 WordPress 的文本或代码模式下工作正常,但在我使用所见即所得编辑器时却不行。
知道如何更改它以使其也可以使用 WordPress 编辑器工作吗?
非常感谢!
这是我正在使用的 JS。
// Set your character limit
var count_limit = 1000;
// Set the initial symbol count on page load
$('#tcepostcontent-wc span').html($('#tcepostcontent').val());
$('#tcepostcontent').on('keyup', function () {
var char_count = $(this).val().length;
var tcepostcontent = $(this).val();
var text_remaining = count_limit - char_count;
// Update the character count on every key up
$('#tcepostcontent-wc span').html(text_remaining);
if (char_count >= count_limit) {
$('#tcepostcontent-wc').css('color', 'red');
$(this).val(tcepostcontent.substr(1, count_limit));
} else {
$('#tcepostcontent-wc').css('color', null);
}
}).after('<p id="tcepostcontent-wc">Max 1000 are available <span>1000</span></p>');
【问题讨论】:
-
您好,有人可以帮忙吗?将不胜感激。
标签: jquery wordpress character-limit