Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <!-- CSS -->
- <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
- <!-- jQuery -->
- <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
- <script type="text/javascript" src="jquery.ba-replacetext.min.js"></script>
- <!-- mes scripts -->
- <script id="allScripts">
- $(document).ready(function() { // Execute when the DOM is fully loaded.
- // add a shortcut method/function
- (function( $ ) {
- // @search: a string used to as search and replace
- // @tag: tag to create wrapping element
- $.fn.wrapHanzi = function(search, tag) {
- return this.each(function() {
- regex = new RegExp(search, 'g'); // create a regex on the fly, See: http://is.gd/BfR9gR
- wrap = '<'+tag+'>'+search+'</'+tag+'>';
- $(this).replaceText( regex, wrap);
- });
- };
- })( jQuery );
- $("#text").wrapHanzi('水', 'easy');
- $("span").wrapHanzi('韓', 'unknow');
- $("span").wrapHanzi('國', 'partial');
- $("span").wrapHanzi('有', 'easy');
- });
- </script>
- <style>
- easy { color: #729fcf; }
- unknow { color: #cc0000; }
- partial { color: #f57900; }
- </style>
- </head>
- <body>
- <div class="wiki-article">TEST TEXT:
- <span id="text">他是<i>北</i>韓國人。他的韓國,是否那裡火山又有火,又有冰冰的了。</span>
- <span id="text">他是<i>北</i>韓國人。他的韓國,是否那裡火山又有火,又有冰冰的了。</span>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment