views:

64

answers:

1

hi i want to find and replace functionality in contentEditable div.i want to add one toolbar in which one find and replace button placed. when one press this button then one popup window open and ask for keyword to search when keyword is given then it will find only in given div id not whole document and highlight it. if any body know about this thing please help me its urgent.

A: 

Is this jquery plugin what you are looking for?

You can call it like this:

jQuery(function()
{
    var options = 
    {
        exact:"exact",
        keys:"lorem ispum"
    }
    $("#myDiv").SearchHighlight(options);
});
Natrium
no its noti don't know about iti just want to do this using javascript.i want find and replace functionality for particular div only not for whole document
you can tell the plugin where he has to look. In the whole document, in all anchors, in one particular div (your case) etc etc.This is javascript, but it is a special library, called jQuery.
Natrium
hi thanks for replay but its not work.i have use the match and split function of string class of javascript and add span tag around searched Keyword.At present it work fine but i belive that it took long time for long string so if any function in jscript which find word in particular div and then select it.If you know then please replay me.Mycode is:var strSearch = divFind.innerHTML;var matchedWords = strSearch.match(new RegExp(txtKeyWord,"ig"));var strSubArray = strSearch.split(new RegExp(txtKeyWord,"ig"));after spliting string by means of keyWord i rejoin them by adding span tag.