在将文本加载到*文本框中之前如何突出显示*文本框中的几个单词

问题描述:

我需要突出显示文本框中的部分文本.因此尝试使用*文本框,但是我无法选择一部分文本,因为可以在Windows窗体的Richtextbox中完成.任何人都可以共享代码.任何帮助将不胜感激.

I need to highlight some portion of text in a textbox. Hence tried using a freetextbox, but I cannot select a portion of text as it can be done in richtextbox in windows forms.Can anyone share code how to do so.Any help will be appreciated.

尝试使用以下方法,将突出显示的文本作为搜索文本传递.
Try using below method, pass highlight text as search text..


("[id


=''_tbSearch'']").highlight(''HIGHLIGHT TEXT'', "highlight");
=''_tbSearch'']").highlight(''HIGHLIGHT TEXT'', "highlight");


jQuery.fn.highlight = function (str, className) {
    var regex = new RegExp(str, "gi");
    return this.each(function () {
        this.innerHTML = this.innerHTML.replace(regex, function (matched) {
            return "<span style="background-color:yellow;border:0px solid gray;">" + matched + "</span>";
        });
    });
};