2010-05-25 96 views
3

我必須突出顯示文本區域中的搜索項目。突出顯示文本區域中的搜索文本

我有一個文本歸檔,搜索按鈕和文本區域。

報價...

After i have enter the search string in the text field whenever i click the search button it highlight the search terms which is available in the text area and focus the search term in text area. 

I have try to do this by using jquery. 

But in mozilla,I can't get the focus to the search term at the time of search. 

I have to scroll down the text area for find the focused search term. 

In I.E. also it doesn't work properly. 

否則,如果突出顯示文本區域搜索詞相關的任何後也明顯。

請指導我做到這一點。

+1

定義'高亮'。你不能真正突出textarea內的任何東西,你可以選擇一個範圍,就是這樣。 – jAndy 2010-05-25 06:05:42

+0

Duplicate http://stackoverflow.com/questions/2863641/highlight-changes/2863719#2863719 – 2010-05-25 12:24:01

回答

2

在Internet Explorer上,我將使用TextRange對象與boundingTop屬性值組合使用。

+0

這些是僅限IE和專有的,這限制了這種解決方案只能在IE中工作。 – 2010-05-25 08:20:35