$
(
".modal_search"
).
on
(
"keyup"
,
function
() {
var
Id
=
$
(
this
).
attr
(
'id'
);
var
searchItem
=
$
(
this
).
val
();
$
(
'#textModal_'
+
Id
).
find
(
".highlight"
).
removeClass
(
"highlight"
);
var
searchText
=
$
(
'#textModal_'
+
Id
).
html
();
var
reg
=
new
RegExp
(
searchItem
,
'gi'
);
var
txt
=
searchText
.
replace
(
reg
,
function
(
str
) {
return
"<span class='highlight'>"
+
str
+
"</span>"
});
if
(
searchItem
!=
""
) {
$
(
'#textModal_'
+
Id
).
html
(
txt
);
}
});