Line breaks in HTML aren't represented by
or
. They can be represented in lots of ways, including the <br>
element, or any block element following another (<p></p><p></p>
, for instance).
If you're using a textarea
, you may find
or
(or
) for line breaks, so:
var text = $("#theTextArea").val();
var match = /
|
/.exec(text);
if (match) {
// Found one, look at `match` for details, in particular `match.index`
}
Live Example | Source
...but that's just textarea
s, not HTML elements in general.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…