JavaScript で、ページに表示されている段落から特定の行を取得することはできますか?
たとえば、ここでは、段落の 3 行目を文字列として取得しようとしています。
JavaScript:
//this function should return the specified line from the specified paragraph.
function getLine(paragraphId, lineNum){
//for example, getLine("sampleParagraph", 1); should return
// tore but year. An from mean on with when sing pain. Oh to as principles devonshire
}
HTML:
<p id = "sampleParagraph">
Instrument cultivated alteration any favourable expression law far nor. Both new like tore but year. An from mean on with when sing pain. Oh to as principles devonshire companions unsatiable an delightful. The ourselves suffering the sincerity. Inhabit her manners adapted age certain. Debating offended at branched striking be subjects.
</p>
これはjsfiddleにあります(段落がどのように表示されるかを示しています):http://jsfiddle.net/RrXWW/