如何添加块编辑器标题字数?

时间:2019-12-01 06:00:13

标签: wordpress

如何在块编辑器的标题中显示字符数?

(function($) {
let countMax = 120;
$('#post-title-0').bind('keydown keyup keypress change',function(){
    let thisValueLength = $(this).val().length;
    let countDown = (countMax)-(thisValueLength);
    $('.wp-block.editor-post-title__block').after(countDown);
    console.log($countDown);
    if(countDown < 0){
        $('.wp-block.editor-post-title__block').css({color:'#ff0000',fontWeight:'bold'});
    } else {
        $('.wp-block.editor-post-title__block').css({color:'#000000',fontWeight:'normal'});
    }
});
$(window).load(function(){
    $('.wp-block.editor-post-title__block').after(countMax);
});
}(jQuery));

但是不行。

0 个答案:

没有答案