jQuery Plugin To Create Textarea With Line Numbering LineNumbers - Download jQuery Plugin To Create Textarea With Line Numbering - LineNumbers

Download jQuery Plugin To Create Textarea With Line Numbering – LineNumbers

Posted on

This time I will share jQuery Plugin and tutorial about jQuery Plugin To Create Textarea With Line Numbering – LineNumbers, hope it will help you in programming stack.

jQuery Plugin To Create Textarea With Line Numbering LineNumbers - Download jQuery Plugin To Create Textarea With Line Numbering - LineNumbers

File Size: 18.5 KB
Views Total: 5212
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another jQuery plugin that makes it easy to track the size of a textarea and display line numbers beside the typed content. It wraps lines intelligently, just because the textarea wraps doesn’t mean it’s actually a new line. Licensed under the GNU General Public License v3.0.

How to use it:

1. Download and put the jQuery LineNumbers plugin after you’ve loaded jQuery library like this:

1 <script src="//code.jquery.com/jquery.min.js"></script>
2 <script src="jquery-linenumbers.js"></script>

2. Just call the function on the target textarea element and the plugin will do the rest.

1 $('textarea').linenumbers();

3. If you want to get fancy there are some additional options you can pass.

01 $('textarea').linenumbers({
02  
03   // The width of the numbers column.
04   // Default should be big enough for 4 columns on a text area with no styles applied.
05   // This will need to be modified for the number of digits you choose, and the textarea styles.
06   col_width: '25px',
07  
08   // The number at which line numbering starts.
09   start: 1,
10  
11   // The number of digits the line numbers should max out at.
12   // This is used for calculating leading space, and does not include the colon.
13   digits: 4
14    
15 });

4. You’ll need to give your text area a set width, or the two line numbers won’t line up right with the text, this has been tested as a px value, but percents should be ok in any format as long as the col_width is the same. Other than that it should work just fine.

1 textarea{
2   width: 555px;
3   height: 270px;
4   font-size: 20px;
5   padding: 10px;
6   line-height: 30px;
7   border-radius: 3px;
8   border: 1px solid #aaaaaa;
9 }

Change log:

2017-09-22

  • bugfix

This awesome jQuery plugin is developed by pgooch. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net