views:

71

answers:

1

Is there a way to get the line number where the element (html tag) sits on the source?

e.g.

<html>
 <head></head>
 <body>
   <div></div>
 </body>
</html

so the <div> tag would be on line 4 in this case. Or if there is a way to get the source code using JS this would solve my problem, too.

+2  A: 

var html = document.getElementByTagName('html')[0].innerHTML

assuming the document starts with html

Then split on \n, assuming you want actual line numbers and not node position or something

mplungjan