jquery

How do you highlight all the words on the page that match an array of words?

风格不统一 提交于 2021-02-18 18:13:04
问题 I want to find all the words on my webpage that match any of the words in a Javascript array, and highlight them (wrap them in special span tags). What's the easiest way to do this? I use jquery. 回答1: Not perfect, but simple and may work: var regex = /(Hello|Goodbye)/g; $('*').each(function() { var $this = $(this); var text = $this.text(); if (regex.test(text)) { $this.html( $this.html().replace(regex, '<span>$1</span>') ); } }); http://jsfiddle.net/pdWAn/ 回答2: Try this these methods

Validating Password and Retype Password

醉酒当歌 提交于 2021-02-18 18:11:48
问题 I am having two textboxes like this : <p> <input type="text" name="NPassword" placeholder="New Password"/></p> <input type="text" name="RNPassword" placeholder="Retype New Password"/> Now,what i want is that on every keypress of Retype New Password It should check if both are same or not.If yes then in green color display it on right side of RNPassword,Otherwise in red color display that both are not same and also disable the submit button of the page.How this can be done please help. 回答1:

Validating Password and Retype Password

筅森魡賤 提交于 2021-02-18 18:11:29
问题 I am having two textboxes like this : <p> <input type="text" name="NPassword" placeholder="New Password"/></p> <input type="text" name="RNPassword" placeholder="Retype New Password"/> Now,what i want is that on every keypress of Retype New Password It should check if both are same or not.If yes then in green color display it on right side of RNPassword,Otherwise in red color display that both are not same and also disable the submit button of the page.How this can be done please help. 回答1:

How do you highlight all the words on the page that match an array of words?

廉价感情. 提交于 2021-02-18 18:11:04
问题 I want to find all the words on my webpage that match any of the words in a Javascript array, and highlight them (wrap them in special span tags). What's the easiest way to do this? I use jquery. 回答1: Not perfect, but simple and may work: var regex = /(Hello|Goodbye)/g; $('*').each(function() { var $this = $(this); var text = $this.text(); if (regex.test(text)) { $this.html( $this.html().replace(regex, '<span>$1</span>') ); } }); http://jsfiddle.net/pdWAn/ 回答2: Try this these methods

Validating Password and Retype Password

筅森魡賤 提交于 2021-02-18 18:10:23
问题 I am having two textboxes like this : <p> <input type="text" name="NPassword" placeholder="New Password"/></p> <input type="text" name="RNPassword" placeholder="Retype New Password"/> Now,what i want is that on every keypress of Retype New Password It should check if both are same or not.If yes then in green color display it on right side of RNPassword,Otherwise in red color display that both are not same and also disable the submit button of the page.How this can be done please help. 回答1:

How to show Ajax response as modal popup

亡梦爱人 提交于 2021-02-18 17:59:08
问题 I have a link on clicking it is sending ajax request and getting response successfully which is html file and I am appending to a div , but I need to show that div as modal popup and I tried something below. in html file <a th:if="${ratingSummary}" href="#" class="small dark account review_ratings_login">Login to write a review</a> <div id="login_for_review" data-toggle="modal" data-target="#reviewLoginModal"></div> in js file $(document).on('click', '.review_ratings_login', function () { var

Parse string of file path to json object

风流意气都作罢 提交于 2021-02-18 17:58:05
问题 I have the list of URL like below. How to convert it into complete json object? My array of URLs. [ "path1/subpath1/file1.doc","path1/subpath1/file2.doc","path1/subpath2/file1.doc","path1/subpath2/file2.doc","path2/subpath1/file1.doc","path2/subpath1/file2.doc","path2/subpath2/file1.doc","path2/subpath2/file2.doc","path2/subpath2/additionalpath1/file1.doc" ] I want this as json object like: { "path1":{ "subpath1":["file1.doc","file2.doc"], "subpath2":["file1.doc","file2.doc"] }, "path2":{

Get data from Materialize css chips

♀尐吖头ヾ 提交于 2021-02-18 17:44:09
问题 I need get data from MaterializeCSS chips, but I don't know, how. $('.chips-placeholder').material_chip({ placeholder: 'Stanici přidíte stisknutím klávesy enter', secondaryPlaceholder: '+Přidat', }); function Show(){ var data = $('.chips-placeholder').material_chip('data'); document.write(data); } <!--Added external styles and scripts--> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0

Running jQuery in Ruby

五迷三道 提交于 2021-02-18 17:43:28
问题 I want to run jQuery in a Ruby application and use it to manipulate an HTML string. (Yes, I know there are other Ruby libraries that can handle that task, but I have a good reason for using jQuery in this case.) Is this possible? I know that I can use ExecJS to execute simple JavaScript code in my Ruby application, but jQuery doesn't seem to be working: irb(main):001:0> require 'execjs' => true irb(main):002:0> require 'open-uri' => true irb(main):003:0> context = ExecJS.compile(open("http:/

Running jQuery in Ruby

♀尐吖头ヾ 提交于 2021-02-18 17:43:06
问题 I want to run jQuery in a Ruby application and use it to manipulate an HTML string. (Yes, I know there are other Ruby libraries that can handle that task, but I have a good reason for using jQuery in this case.) Is this possible? I know that I can use ExecJS to execute simple JavaScript code in my Ruby application, but jQuery doesn't seem to be working: irb(main):001:0> require 'execjs' => true irb(main):002:0> require 'open-uri' => true irb(main):003:0> context = ExecJS.compile(open("http:/