What I want is simple. I have an input field and I want to check what items from an unordered list (ul
) contain the input's value.
So, I have this:
$('input#search').keyup(
function() {
var value = $(this).val();
if (value.length > 0) {
var patt = /value/g;
console.log(patt);
$('ul#list li').filter(function() {
return (patt.test($(this).html()));
});
}
}
);
My problem here is that if, for example, the value of the input is 'abcd' patt will be /value/g
instead of /abcd/g
so I want to know how can I insert the value in the pattern.