如何在块编辑器的标题中显示字符数?
(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));
但是不行。