Skip to main content
added 24 characters in body
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

I know of a way to add a character counter to the excerpt metabox in WP, but I would like to add a character counter to a custom metabox. The following script is getting the counter in the metabox, which has tabs, but it isn't counting. Any help would be great. Thanks, it's my first question in StackExchange.

jQuery(document).ready(function(){
    jQuery("#bgnp-metabox-tabs").after("<p style=\"text-align:left;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"bgnp-metabox-tabs\" readonly=\"\"> <small>character(s).</small></p>");
    jQuery("#feed").val(jQuery("#excerpt").val().length);
    jQuery("#bgnp-metabox-tabs").keyup( function() {
        jQuery("#bgnp_metabox_tabs").val(jQuery("#excerpt").val().length);
    });
});

});

The counter appears in all of the tabs, but I only want it in the tab "#feed"

I know of a way to add a character counter to the excerpt metabox in WP, but I would like to add a character counter to a custom metabox. The following script is getting the counter in the metabox, which has tabs, but it isn't counting. Any help would be great. Thanks, it's my first question in StackExchange.

jQuery(document).ready(function(){
jQuery("#bgnp-metabox-tabs").after("<p style=\"text-align:left;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"bgnp-metabox-tabs\" readonly=\"\"> <small>character(s).</small></p>");
jQuery("#feed").val(jQuery("#excerpt").val().length);
jQuery("#bgnp-metabox-tabs").keyup( function() {
    jQuery("#bgnp_metabox_tabs").val(jQuery("#excerpt").val().length);
});

});

The counter appears in all of the tabs, but I only want it in the tab "#feed"

I know of a way to add a character counter to the excerpt metabox in WP, but I would like to add a character counter to a custom metabox. The following script is getting the counter in the metabox, which has tabs, but it isn't counting. Any help would be great. Thanks, it's my first question in StackExchange.

jQuery(document).ready(function(){
    jQuery("#bgnp-metabox-tabs").after("<p style=\"text-align:left;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"bgnp-metabox-tabs\" readonly=\"\"> <small>character(s).</small></p>");
    jQuery("#feed").val(jQuery("#excerpt").val().length);
    jQuery("#bgnp-metabox-tabs").keyup( function() {
        jQuery("#bgnp_metabox_tabs").val(jQuery("#excerpt").val().length);
    });
});

The counter appears in all of the tabs, but I only want it in the tab "#feed"

edited tags
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459
Source Link

Add character count to custom metabox

I know of a way to add a character counter to the excerpt metabox in WP, but I would like to add a character counter to a custom metabox. The following script is getting the counter in the metabox, which has tabs, but it isn't counting. Any help would be great. Thanks, it's my first question in StackExchange.

jQuery(document).ready(function(){
jQuery("#bgnp-metabox-tabs").after("<p style=\"text-align:left;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"bgnp-metabox-tabs\" readonly=\"\"> <small>character(s).</small></p>");
jQuery("#feed").val(jQuery("#excerpt").val().length);
jQuery("#bgnp-metabox-tabs").keyup( function() {
    jQuery("#bgnp_metabox_tabs").val(jQuery("#excerpt").val().length);
});

});

The counter appears in all of the tabs, but I only want it in the tab "#feed"