Здравствуйте, у меня вопрос, почему у меня учитывается регистр при поиске?
CODE ( javascript):
скопировать код в буфер обмена
$(document).ready(function(){ $('#body').click(function(){ $('#test-table').find('span').removeClass('light'); }); $('#search-now').click(function(){ $('#test-table').find('span').removeClass('light'); var phrase = $('#search-inp').val(); jQuery(":contains("+phrase+")").not(":has(:contains("+phrase+"))").each(function () { var that = $(this); var html = that.html(); html = html.replace(new RegExp(phrase, 'gi'), '<span class="light">'+phrase+'</span>'); that.html(html); var n = $('.light').eq(0).offset().top; $("body,html").animate({ scrollTop: n }, 1); }); }); $('#search').submit(function(){ $('#test-table').find('span').removeClass('light'); var phrase = $('#search-inp').val(); jQuery(":contains("+phrase+")").not(":has(:contains("+phrase+"))").each(function () { var that = $(this); var html = that.html(); html = html.replace(new RegExp(phrase, 'gi'), '<span class="light">'+phrase+'</span>'); that.html(html); var n = $('.light').eq(0).offset().top; $("body,html").animate({ scrollTop: n }, 1); }); return false; }); });
CODE ( html):
скопировать код в буфер обмена
<form class='large-4 columns large-centered' id='search' > <div class="row collapse large-12 columns search-space"> <div class="small-10 columns"> <input type="search" id='search-inp' placeholder="Поиск..."/> </div> <div class="small-2 columns"> <input type='button' class="prefix" value='' id='search-now'/> </div> </div> </form>
|