針對全文透過JS來做重點標示

在前陣子有個Case是要處理搜尋結果頁的部分,要將搜尋出來的內容利用關鍵字進行Highlight,所以有了下面這個範例,是利用正規表示法+JS進行處理,會無視搜尋關鍵字的大小寫,若要區分大小寫可將第45行中的gi,改為g就好,以下是範例頁面的Code,也可以直接連結到範例頁面試試看。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Highlight Text Sample</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <style>
        .f-red{
            color: red;
            font-weight: bold;
        }
    </style>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="input-group mb-3">
				<input type="text" id="hightlightText" value="我" class="form-control">
				<div class="input-group-append">
				<button class="btn btn-primary" type="button" id="activeBtn">Button</button>
			</div>
		</div>
		</div>
		<div id="content" class="row"></div>
	</div>
</body>
</html>
var htmlText = "";
$.ajax({
    url: "highLightText.txt",
    async: false,
    success: function(response){
        htmlText = response;
    }
});
$("#content").html(htmlText);

var hightlightText = $("#hightlightText").val();
$.fn.highlight = function(what,spanClass) {
    return this.each(function(){
        var container = this,
            content = container.innerHTML,
            pattern = new RegExp('([<.]*)(' + what + ')([<.]*)','gi'),
            replaceWith = '$1<span ' + ( spanClass ? 'class="' + spanClass + '"' : '' ) + '">$2</span>$3',
            highlighted = content.replace(pattern,replaceWith);
        container.innerHTML = highlighted;
    });
}
$('#content').highlight(hightlightText,'f-red');

$("#activeBtn").click(function(){
    $("#content").html(htmlText);
    var hightlightText = $("#hightlightText").val();
    $('#content').highlight(hightlightText,'f-red');
});
<p>給到王平銀日持風臺色營對合我過友的、造也在乎費靜臺白國:投無心面策一十人力委了可來沒?動區雲溫好面些、味又動高兒可來成的常他告臺布來處本我:界沒乎真不下老關,業實了種童不成他神舉經公黑下方、小利頭適不保講以心感校趣facebook不他到代易上海。一設開物愛研題來一下一國該要、機出又際各內案名相落的沒上年水部求沒山大式理密。房長裡再造級……童面費後務,風一也本名。太一息品的看統配北心他合情分子的經易民告只?</p><p>進安太,狀立?</p><p>文它接。於能病到腦反的題光,異卻道華找重有地北得了,去她定究愛,局自明加汽容看google及兒已的facebook兩:未不乎動常看選的所國半成著坐靈人一本成英一環處教時告即小!後也臺市開半:技月家,展教子、起構的相要從王排,臉外產便上。運自片同合可家小的部方單美哥人頭讀更外前喜民,有不馬的,你風的;心說火來的……全起飛事影。</p><p>拉為三參。體成和正地該名玩公可等Google學素母為收營……時世的回過高布家不生世存故研,為親總手?行眼長藝想海能和門新小認中日每收交金又成Facebook來而出還內界官我告展了戲有了的的?</p><p>由在下代保不著春原還其元上計一中合小,合的難修技空麼母於車當為下大灣的更吸如果中法照日目Facebook評一種父魚,目發體必詩遊完到往她數他來們標民。有西加邊,的已明得國多、的且看花性小下時都葉輪我後?觀復大物則的示的戰品照!失分量認法。而日媽運那麼個,名目石師越慢面我的古望科流身代安次野大的大深為坡打南發入定筆境產飛東資再變新西一滿價由親爭水道不合不性,google去實差來。球寶的了放車早大馬產場到使引是名最少不人經進人聲經光我,活連第,風軍工星費書它出。情會了每記、能時外社班們人第底月草。股本我google也。是不大日生未向心獲投時成到告平一樣爸音裡使上後讀如推其界明國報問小國快,打問盡自;裡物候小的了民品著家爭行全位?這時的足子一可等學讀不其今當前生好年點自星我藝資做精只基家他命方資前能一們?facebook美十本世高月有量用不善大一王毒跑們這們其可理出一樣規加還人和其寶再西因觀文葉態,灣木學定,個一知論參細已車不;但地口不別的務際千信記車南的、在營該科讓,我子機數年原是紅戰動感問象易一人所消登衣以他型新三。童愛早十以民國止最時構空夜包害石識小導開Google足活。都是身也個紙失八模用精想修速情不散靜到了小神幾會比找銷消之:行的結星才山風人地。山情資器產們這還上想明生。</p><p>調活前育她一來資!車各向進方加取而向成:使知過不,賽舉師皮;早而運星傳等之是法死技斯身不放facebook也日綠手上,不還國、紅球色統形不發過青展國,運市包,雜開基民場操造奇證;地的會沒工星人去,我作感影她創書處營器病……期有生寫看果公們工張,什館進因了入麼對體算兒低汽?靜但開目地、好久我期展今視義本:政義相會位例皮,加情地分朋學客助……年認校分存片常一是。</p><p>刻爾全否便,此前大檢生生回電性其供假調神約獎因突自阿的。</p>

實際動手玩看看↓↓

You may also like...

384,785 Responses

  1. Diplomi_vrer表示:

    купить диплом театрального prema365-diploms.ru .

  2. mostbetmatySi表示:

    Recevez des conseils d’experts sur Mostbet Maroc | Telechargez Mostbet et accedez aux paris sportifs en quelques clics | Obtenez des bonus d’inscription en rejoignant Mostbet Maroc | Jouez en ligne en toute confiance avec Mostbet | Retrouvez des cotes avantageuses sur Mostbet pour chaque evenement | Mostbet propose des jeux de casino en direct pour plus de realisme | Trouvez les meilleures cotes de paris sur Mostbet | Mostbet vous propose des options de paiement securisees | Essayez Mostbet pour une experience de jeu inoubliable mostbet casino mostbet casino.

  3. Diplomi_nxer表示:

    купить диплом ру prema365-diploms.ru .

  4. mostbetmaygSi表示:

    Decouvrez une large gamme de jeux sur Mostbet Maroc | Telechargez Mostbet et accedez aux paris sportifs en quelques clics | Choisissez Mostbet pour une experience de jeu inegalee | Pariez sur les grands evenements sportifs avec Mostbet | Mostbet assure un environnement de jeu sur et protege | Profitez des meilleures offres de paris en ligne avec Mostbet | Mostbet, votre partenaire pour les paris sportifs au Maroc | Mostbet offre un environnement de jeu juste et securise | Telechargez et commencez a parier avec Mostbet des aujourd’hui telecharger casino mostbet http://www.telecharger-mostbet-maroc.com.

  5. Тут можно преобрести купить сейф для охотничьего карабина сейф для оружия купить москва

  6. mostbetmabgSi表示:

    Profitez des meilleures cotes avec Mostbet pour vos paris sportifs | Telechargez Mostbet et accedez aux paris sportifs en quelques clics | Decouvrez l’experience des paris en ligne avec Mostbet Maroc | Jouez en ligne en toute confiance avec Mostbet | Mostbet Maroc est l’un des meilleurs sites de paris en ligne | Rejoignez Mostbet et decouvrez des bonus quotidiens | Telechargez l’application Mostbet pour acceder aux meilleurs jeux | Mostbet vous propose des options de paiement securisees | Pariez facilement sur Mostbet et gagnez de grosses recompenses mostbet telecharger telecharger-mostbet-maroc.com.

  7. mostbetmaeqSi表示:

    Recevez des conseils d’experts sur Mostbet Maroc | Obtenez des promotions speciales en telechargeant Mostbet | Pariez en toute securite avec l’application Mostbet Maroc | Pariez sur les grands evenements sportifs avec Mostbet | Des bonus de bienvenue sont disponibles sur Mostbet | Mostbet propose des jeux de casino en direct pour plus de realisme | Mostbet garantit des paiements rapides et sans tracas | Participez aux evenements sportifs avec des cotes elevees sur Mostbet | Mostbet Maroc est ideal pour les amateurs de paris sportifs telecharger casino mostbet http://www.telecharger-mostbet-maroc.com.

  8. CarrollUnton表示:

    deneme bonusu veren siteler betturkey betturkey.com http://denemebonusuverensiteler.top/# deneme bonusu veren siteler yerliarama.org

  9. cathleenme2表示:

    10 best anal onlyfans accounts with hot only fans anal
    https://urine-tickling.fetish-matters.net/?kierra-katerina

  10. кожзам для мебели купить [url=www.iskusstvennaya-kozha-dlya-mebeli-kupit.ru/]кожзам для мебели купить[/url] .

  11. купить искусственная кожа розницу https://iskusstvennaya-kozha-dlya-mebeli-kupit.ru/ .

  12. Diplomi_jler表示:

    диплом на заказ prema365-diploms.ru .

  13. согласование перепланировки квартиры в москве стоимость [url=https://www.stoimost-soglasovaniya-pereplanirovki-kvartiry.ru]согласование перепланировки квартиры в москве стоимость[/url] .

  14. сколько стоит проект перепланировки квартиры https://stoimost-soglasovaniya-pereplanirovki-kvartiry.ru .

  15. Тут можно преобрести оружейные шкафы купить сейф для ружья в москве

  16. vanessagt2表示:

    Asian movies fresh korean xxx asian bed asian black fucking
    http://cfnm-porn.plushie.gigixo.com/?tess-jadyn

    best porn videos free online watch hayden russon gay porn men suckingmen porn ammeture porn med evil porn

  17. Jeanette表示:

    Learn What Private ADHD Assessments Tricks The Celebs Are
    Using private adhd assessment exeter – Jeanette,

  18. Plinko, a game that has won the affection of countless players, is not just a game of chance; it’s an thrilling endeavor that blends entertainment with the potential for real money rewards. This article examines the different features of the plinko demo, including its online versions, the gaming application, and the joy of engaging in real-money Plinko gameplay. Whether you’re a experienced participant or a newcomer eager to discover what this game is all about, this guide will provide you with everything you need to know.

    The Essential Guide to Plinko Basics Plinko is a simple yet engaging game that comes from the popular television game show “The Price Is Right.” The game involves a standing board filled with nails, where players drop a ball from the top and watch it navigate through the pegs until it lands in one of several slots at the bottom, each with a different payout value. The randomness of the ball’s path creates a sense of thrill, making each drop an exciting and suspenseful event.

    The beauty of Plinko lies in its straightforwardness. Anyone can join in and appreciate it without needing a thorough grasp of complex strategies. This accessibility has made it a favorite among casual gamers and enthusiasts too. With the rise of technology, Plinko has expanded into the online gaming world, offering different venues to enjoy this cherished pastime.

    Accessing Plinko: The Mobile Application With the growing popularity of mobile gaming, the Plinko app has become a popular choice for those who want to experience it on the go. Available for both Android and iOS devices, the Plinko app offers a fluid user experience. Players can easily download the app from their respective app stores, allowing them to play anytime and anywhere.

    The Plinko app is designed with the needs of gamers considered. Its easy-to-navigate design makes it easy for new players to grasp the gameplay and begin playing without delay. Moreover, the app often includes additional features such as daily bonuses, leaderboards, and multiplayer options, adding depth to the play experience. For players seeking to maximize their enjoyment, the Plinko app download is a simple task that opens up a world of gaming possibilities.

    URL: http://www.ardenneweb.eu/archive?body_value=When+playing+Plinko+online+for+cash%2C+players+must+be+mindful+of+the+challenges+associated.+Like+all+gambling+activities%2C+there+is+a+chance+of+sustaining+losses%2C+so+it+is+important+to+gamble+carefully.+Many+online+casinos+offer+the+option+to+engage+with+a+no-cost+version+through+demo+versions.+The+Plinko+free+demo+provides+players+with+a+safe+space+to+%3Ca+href%3D%22https://realitysandwich.com/_search/%3Fsearch%3Dpractice%22%3Epractice%3C/a%3E+and+understand+the+game+mechanics+before+wagering+real+money.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Grasping+the+Fundamentals+of+Plinko+Plinko+is+a+straightforward+yet+captivating+game+that+was+inspired+by+the+popular+television+game+show+%22The+Price+Is+Right.%22+The+game+involves+a+standing+board+filled+with+nails%2C+where+players+drop+a+ball+from+the+top+and+watch+it+travel+through+the+pegs+until+it+lands+in+one+of+several+slots+at+the+bottom%2C+each+with+a+different+payout+value.+The+randomness+of+the+ball%27s+path+creates+a+sense+of+thrill%2C+making+each+drop+an+exciting+and+suspenseful+event.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Engaging+in+Real+Money+Plinko+Gameplay+One+of+the+most+exciting+elements+of+Plinko+is+the+opportunity+to+play+for+real+money.+Various+online+casinos+offer+the+Plinko+game+online%2C+allowing+players+to+experience+the+thrill+of+wagering+and+potentially+winning+cash+prizes.+These+platforms+typically+include+multiple+versions+of+the+game%2C+each+with+its+unique+rules+and+payout+structures.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Using+Plinko+APK+for+Easy+Gameplay+For+Android+users%2C+the+Plinko+APK+is+an+great+alternative+for+accessing+the+game+directly+from+their+devices.+The+APK+format+allows+users+to+get+the+Plinko+app+without+going+through+standard+download+methods.+This+is+particularly+useful+for+players+in+regions+where+the+app+may+not+be+available+on+the+Google+Play+Store.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Plinko+App:+Enjoying+the+Game+on+Your+Mobile+Device+With+the+growing+popularity+of+mobile+gaming%2C+the+Plinko+app+has+become+a+popular+choice+for+those+who+want+to+experience+it+on+the+go.+Available+for+both+Android+and+iOS+devices%2C+the+Plinko+app+offers+a+fluid+user+experience.+Players+can+easily+download+the+app+from+their+respective+app+stores%2C+allowing+them+to+engage+in+gameplay+at+their+convenience.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++The+beauty+of+Plinko+lies+in+its+straightforwardness.+Anyone+can+play+and+enjoy+it+without+needing+a+comprehensive+knowledge+of+difficult+rules.+This+accessibility+has+made+it+a+beloved+game+for+everyday+gamers+and+enthusiasts+too.+With+the+rise+of+technology%2C+Plinko+has+found+its+way+the+online+gaming+world%2C+offering+different+venues+to+enjoy+this+cherished+pastime.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Getting+the+Plinko+APK+is+a+straightforward+process%2C+but+players+should+ensure+they+obtain+the+file+from+a+safe+site+to+avoid+security+risks.+Once+installed%2C+the+Plinko+game+provides+an+engaging+experience+that+can+be+enjoyed+at+any+time.+With+the+rise+of+mobile+gaming%2C+the+Plinko+APK+serves+as+a+great+resource+for+players+looking+to+play+their+beloved+game+wherever+they+are.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++The+Plinko+app+is+designed+with+user+experience+in+mind.+Its+intuitive+interface+makes+it+straightforward+for+newcomers+to+understand+the+rules+and+start+playing+immediately.+Moreover%2C+the+app+often+includes+extra+perks+such+as+daily+bonuses%2C+leaderboards%2C+and+multiplayer+options%2C+adding+depth+to+the+play+experience.+For+players+seeking+to+maximize+their+enjoyment%2C+the+Plinko+app+download+is+a+quick+and+easy+method+that+opens+up+a+world+of+gaming+possibilities.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Final+Thoughts:+The+Allure+of+Plinko+In+conclusion%2C+Plinko+is+more+than+just+a+casual+betting+game;+it%E2%80%99s+an+exciting+journey+that+has+enraptured+a+global+audience.+Whether+you%E2%80%99re+playing+on+your+mobile+device%2C+engaging+with+the+app%2C+or+trying+your+luck+at+an+online+casino%2C+Plinko+offers+an+exciting+mix+of+fun+and+the+chance+for+real+cash+rewards.+The+game%27s+accessibility+makes+it+suitable+for+everyone%2C+ensuring+that+anyone+can+get+involved.+So+why+not+give+Plinko+a+try+today%3F+You+might+just+find+yourself+becoming+enamored+with+the+thrill+of+Plinko.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++The+Thrill+of+Stake+Plinko+In+recent+years%2C+the+emergence+of+cryptocurrency+has+transformed+the+realm+of+online+gaming%2C+and+Plinko+is+no+exception.+Stake+Plinko+is+a+special+adaptation+of+Plinko+that+allows+players+to+wager+using+cryptocurrencies.+This+version+combines+the+excitement+of+traditional+Plinko+with+the+perks+of+digital+currencies%2C+such+as+faster+transactions+and+enhanced+security.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Plinko%2C+a+game+that+has+enthralled+a+multitude+of+fans%2C+is+not+just+a+game+of+chance;+it%27s+an+exhilarating+experience+that+merges+enjoyment+and+the+potential+for+real+money+rewards.+This+article+delves+into+the+various+aspects+of+the+%3Ca+href%3D%22https://plinko-online.in/%22%3Eplinko+game+download%3C/a%3E%2C+including+its+virtual+adaptations%2C+the+Plinko+app%2C+and+the+thrill+of+playing+Plinko+online+for+real+money.+Whether+you%E2%80%99re+a+veteran+gamer+or+a+newcomer+eager+to+learn+about+what+this+game+is+all+about%2C+this+guide+will+provide+you+with+comprehensive+insights.%3Cbr%3E+%3Cbr%3E++%3Cbr%3E+%3Cbr%3E++Stake+Plinko+often+provides+distinct+advantages%2C+such+as+varying+odds+and+different+payout+structures.+Players+can+experience+traditional+gameplay+with+a+twist+of+digital+currency%2C+making+it+an+attractive+option+for+those+who+are+familiar+with+digital+currencies+and+looking+for+innovative+gaming+experiences.

    The Thrill of Playing Plinko Online for Cash One of the most attractive features of Plinko is the opportunity to play for real money. Various online casinos offer the Plinko game online, allowing players to engage in the excitement of betting and potentially winning cash prizes. These platforms typically provide various Plinko options, each with its own gameplay mechanics and cash rewards.

    When playing Plinko online for cash, players must be mindful of the risks involved. Like all gambling activities, there is a chance of losing money, so it is crucial to bet wisely. Many online casinos offer the option to play Plinko for free through demo versions. The no-cost Plinko version provides players with a secure setting to learn and understand the game mechanics before wagering real money.

  19. Тут можно преобрести оружейный сейф москва стоимость сейфа для оружия

  20. mostbetmaxfSi表示:

    Des prix competitifs et des bonus exceptionnels sur Mostbet | Mostbet offre des options de paris pour chaque evenement sportif | Decouvrez l’experience des paris en ligne avec Mostbet Maroc | Telechargez l’application Mostbet et jouez partout ou vous etes | Rejoignez la communaute des joueurs sur Mostbet Maroc | Telechargez et decouvrez la plateforme dynamique de Mostbet Maroc | Mostbet, votre partenaire pour les paris sportifs au Maroc | Participez aux evenements sportifs avec des cotes elevees sur Mostbet | Mostbet vous offre des opportunites de gains elevees telecharger mostbet site officiel telecharger mostbet site officiel.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。