Display line number in textarea

拜拜、爱过 提交于 2019-12-21 03:45:45

问题


I want to display the line number in a textarea like this is possible in jQuery:

I looked for answers on SO but I can't find what I want

Display current line and column number for a textarea

Limit number of lines in textarea and Display line count using jQuery

Also, the solution I tried from the JSFiddle provided from the comments show me the textarea like this:

which line 1234 is the first line and the second line is 5678


回答1:


Download the plugin found here: http://alan.blog-city.com/jquerylinedtextarea.htm

Usage:

$(function() {

  // Target all classed with ".lined"
  $(".lined").linedtextarea(
    {selectedLine: 1}
  );

  // Target a single one
  $("#mytextarea").linedtextarea();

});

Fully functional demo: http://files.aw20.net/jquery-linedtextarea/jquery-linedtextarea.html (web.archive)



来源:https://stackoverflow.com/questions/8431670/display-line-number-in-textarea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!