Can someone help me with lowercase and uppercase? If I typing in input "long" I have only "long" in results, but I want have in results both "long" and "Long", else if I typing "Long" I want have in results both "Long" and "long".
There is my code:
html
<input id="search" type="text" placeholder="Search" />
<div class="post">Long long</div>
jQuery
$('#search').on('keyup', function(event) {
var keyword = event.currentTarget.value;
highlight('.post', keyword);
});
function highlight(selector, keyword) {
$(selector).each(function(index, element) {
var $element = $(element);
var original = $element.data('originalText');
if (original == undefined) {
original = $element.html();
$element.data('originalText', original);
}
$element.html(original.replace(keyword, '<span class="highlight">' + keyword + '</span>'));
});
}
css
.highlight {
background: yellow;
}
and link to fiddle https://jsfiddle.net/txow4Lps/