をしません:JS - 私が最初に検索(ハイライトテキスト)を実行する場合は、その後のセクションに.click私が検索したテキストをハイライト表示し実行する場合たい仕事
$(document).keypress(function(e) {
if(e.which == 13) {
e.preventDefault();
highlightSearch();
}
});
function highlightSearch() {
$('span').removeClass('highlighted');
var text = document.getElementById("query").value;
var query = new RegExp("(\\b" + text + "\\b(?!([^<]+)?>))", "gim");
var e = document.getElementById("searchText").innerHTML;
var enew = e.replace(/(<span class='highlighted'>|<\/span>)/igm, "");
document.getElementById("searchText").innerHTML = enew;
var newe = enew.replace(query, "<span class='highlighted'>$1</span>");
document.getElementById("searchText").innerHTML = newe;
}
コードストップの作業の後、この部分:
$('.service-box').click(function(){
$('#siteOverlay').addClass('overlay-active');
$('#popupWindow').addClass('service-active');
$('#popupWindow #contentBox').html($(this).html());
});
.click()はこれ以上登録されません。何が間違っているのか分かりません。あなたは私がこれを解決するのを助けてくれますか?
ありがとうございます!
Btw:常にクエリ値をエスケープする必要があります。 – dude
最初にエスケープクエリの値はどういう意味ですか? –
http://stackoverflow.com/questions/10646142/what-does-it-mean-to-escape-a-string – dude