Javascript string search string in array not working here is my code
Mycode
var array = ["foo","fool","cool","god",'searchstring'];
var src_keyword="";
$("#search_str").click(function(){
src_keyword=$("#str_search").val();
find(array,src_keyword)
});
function find(arr,src_keyword1) {
var result = [];
alert(src_keyword1);
//src_keyword1="oo";
for (var i in arr) {
var search = new RegExp(src_keyword1, "gi");
if (arr[i].match(search)) {
alert(arr[i])
result.push(arr[i]);
}
}
return result;
}
Html
<input type="text" id="str_search" value=" "/>
<input type="button" id="search_str" value="search" />
thanks in advance