Skip to content

Instantly share code, notes, and snippets.

@lrtfm
lrtfm / linenumber.js
Created May 11, 2012 16:22
Add line number for text in element "<pre><code>".
//add line num for the code in Elenment "<pre><code>"
function addLineNum()
{
try {
var mycode = document.getElementsByTagName("code");
var space = /^[ \t\b]*$/;
//var times = mycode.length;
for (var loop = 0; loop < mycode.length; ) {
var s = mycode[loop];
var p = s.parentNode;