Search and Highlight in jQuery

http://jsfiddle.net/UPs3V/291/ var src_str = $(“#test”).text(); var term = “my text”; term = term.replace(/(\s+)/,”(<[^>]+>)*$1(<[^>]+>)*”); var pattern = new RegExp(“(“+term+”)”, “gi”); src_str = src_str.replace(pattern, “<mark>$1</mark>”); src_str = src_str.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/,”$1</mark>$2<mark>$4″); $(“#test”).html(src_str); try this one it may help you

Highlights subString in the TableCell(s) which is using for JTable filetering

JXTable can do so via a Highlighter – see swinglabs-demos for an example (MatchingTextHighlighter in the search demo) – there a background highlight is applied by a Painter. You can do something like that manually somewhere in your renderer. If using a JLabel as renderingComponent, you basically have to find parts of the text that … Read more

Highlight search terms (select only leaf nodes)

[See it in action] // escape by Colin Snover // Note: if you don’t care for (), you can remove it.. RegExp.escape = function(text) { return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, “\\$&”); } function highlight(term, base) { if (!term) return; base = base || document.body; var re = new RegExp(“(” + RegExp.escape(term) + “)”, “gi”); //… just use term … Read more

Android – Keep ListView’s item highlighted once one has been clicked

Put a position variable for selected item. Change the position in onItemClicked() method. Check the selected position in List Adapter inside getView() and set the background for the selected item. public class TestAdapter extends BaseAdapter { private Context context; private ArrayList<TestList> testList; private int selectedIndex; private int selectedColor = Color.parseColor(“#1b1b1b”); public TestAdapter(Context ctx, ArrayList<TestList> testList) … Read more

How to make HTML Text unselectable [duplicate]

You can’t do this with plain vanilla HTML, so JSF can’t do much for you here as well. If you’re targeting decent browsers only, then just make use of CSS3: .unselectable { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } <label class=”unselectable”>Unselectable label</label> If you’d like to cover older browsers … Read more