Join the Conversation


  1. Really good man, appreciate your work, hope you improve with new features!
    I only had some problems with the blank lines, the plugin doesn’t count them when they are in the middle of the text.

    Can you check this? Tks again, Pedro.

    1. Thanks for the feedback! Can you post an example of some text that won’t be counted correctly? I tried adding a few blank lines between the text in my demo ( but it seemed to work. I am definitely planning on updating it, hopefully soon. Among the changes I’ll make are increased accuracy. Thanks again for stopping by.

  2. Something like:

    “Enter some (line end)
    Text here (line end)
    and click the button to view stats

    (line end)”

    I tried with Chrome (last version) and Firefox (last stable). The demo counts 7 lines and only that. All the other values return 0;

    1. If the whitespace (or any non-wrapable sequence of characters) goes to the very end of the line, the plugin will sometimes miscount it as two lines, even if it doesn’t quite wrap. This is a known issue which I’m still working on. I wonder if that’s what is happening?

      1. No, is not about the wrap-able lines. Is about the blank lines, On the example I wrote above, the forth line is a blank line, right? But is not being considered as one.

        1. I’m sorry about that; I’ll have to do more rigorous testing in Chrome for the next release. Thank you for reporting the error. I’ll let you know when I find out what caused it.

  3. Hey man!

    I liked your plugin but for some reason it doesn’t work in my case. The code on works fine, but as soon I try to implement it on my stuff it breaks down.

    It turns out that it doesn’t calculate the width of span – so he returns 0. Anyway I tried to fix it, but no avail. So I turned to good old solution, and I’ve added another option value, “averageFontWidth”. You can guess what it does 😛

    PS: Some of my clients wanted to skin the text area, so I am developing skinning plugin for that. Your plugin is one of my dependences 🙂

    1. Thanks for visiting! I’m glad you like the plugin! 🙂

      Some browsers are weird when it comes to calculating width on hidden elements; that might be why the width is returning 0. Also, I am planning on releasing a new version of my plugin soon (hopefully this month) so check back often! The API will be rewritten, so your plugin won’t work with the updated version. Looking forward to seeing it though.

  4. Nice little plugin. I easily managed to use it on multiple textareas, as follows:

          var $_this = jQuery(this);
          var r = jQuery.countLines($_this);
    1. Thank you for the bug report.

      This is a known problem. Currently, the plugin doesn’t account for blocks of text that can’t be wrapped at any natural character. This behavior is different across browsers. In addition to that, there are several CSS attributes that modify how text wraps (take a look: Again, these work differently across browsers.

      I am hoping to fix this in the next release of the plugin. Unfortunately, I haven’t had time recently to work on any plugins.

  5. I think the lines (where the counting for the blank lines happens)

    if ($.trim(value) == “”)

    should be

    if ($.trim(v) == “”)

    for blank lines are counted correctly?

    Nice plugin though! Keep up the good work!

    P.S – I checked the JSFiddle since the download link doesn’t work (it says the plugin site is under development)

      1. Cool! That was quick!

        Really liked the plugin. I am new to jQuery and just starting out, this plugin helped me loads. 🙂

        Thanks again.

  6. Hi Colwin,

    Thanks for catching the bug :). Maybe I can push out a new version of the plugin tonight, while I’m still motivated. Anyway, jQuery’s plugin site was nuked (in error) by the admins. When I release the latest version, I’m going to migrate it to Google Code.



Leave a comment

Leave a Reply