javascript - 在文本区域中显示行号

标签 javascript jquery numbers textarea line

我想在 textarea 中显示行号,这在 jQuery 中是可能的:

enter image description here

我在 SO 上寻找答案,但我找不到我想要的东西

Display current line and column number for a textarea

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

此外,我从评论提供的 JSFiddle 中尝试的解决方案向我展示了这样的文本区域:

enter image description here

第一行是1234,第二行是5678

最佳答案

在此处下载插件:http://alan.blog-city.com/jquerylinedtextarea.htm

用法:

$(function() {

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

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

});

全功能演示:http://files.aw20.net/jquery-linedtextarea/jquery-linedtextarea.html (web.archive)

关于javascript - 在文本区域中显示行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8431670/

相关文章:

javascript - 如何映射包含另一个我想要映射的对象并从中返回 JSX 的对象?

javascript - 尝试通过 npm 加载 jQuery 插件

javascript - Chrome 中的 "Cannot create answer in state stable"

javascript - 在 setInterval 中调用 WebService

Java在两个给定值之间生成随机数

javascript - 在 Javascript(或 Jquery)中将函数声明为变量

javascript - 似乎无法将事件处理程序绑定(bind)到 Angular.js 中指令生成的标记

Jquery POST 在 spring mvc 中给出 403 禁止错误

batch-file - 批处理脚本: How to convert letters into their predefined set of numerical counterparts then sum them up

java - 如何分解一个数字并将其数字相乘?