0
例如,假設我想強調的文本塊中的一個文本字段,然後按一個鏈接與<highlight>...</highlight>
標籤(例如<highlight>(highlighted text appears here)</highlight>
)封閉文本 - 例如爲:如何使用JavaScript將帶突出顯示的文字與某些標籤放在textarea中?
<textarea id="comment-body"></textarea>
<a href="#" class="highlight-words" onclick="highlightWords()">Highlight</a>
function highlightWords(){
// code for enclosing highlighted text in textarea appears here
}
任何想法?
我真的不知道爲什麼,當問題和答案都非常不同,這被標記爲重複。這是我在StackOverflow上看到的最奇怪的事情之一。我很高興在過度熱情的節制結束這個問題之前得到了我想要的答案。 – sjsc