Line breaks in HTML are not represented \n or \r . They can be represented in a variety of ways, including the <br> element or any block element following the other ( <p></p><p></p> , for example).
If you use textarea , you can find \n or \r (or \r\n ) for line breaks, so:
var text = $("#theTextArea").val(); var match = /\r|\n/.exec(text); if (match) { // Found one, look at `match` for details, in particular `match.index` }
Live Example | Source
... but it's just textarea s, not HTML elements at all.
TJ Crowder Feb 28 '13 at 8:47 2013-02-28 08:47
source share