javascript - Using :contains to found a text jquery -


in past questions, asked how can hide element's depending text specific tag use span, 1 answer says can use

html

<div class="container-a">                   <div class="container-b">                     <div class="container-c">                         <table border="1"style="width:98%">                           <tr>                             <td width="220" height="100">                               1                             </td>                             <td width="200">                               2                             </td>                             <td width="300">                              <div id="step_form_1" class="order-steps">                               <span>25/01/2016 13:30</span>                               <div>                             </td>                             <td width="120">                               4                             </td>                              <td width="120">                               5                             </td>                           </tr>                         </table>                       </div>                     <div class="side-color">                     </div>                     <div class="tam">                     </div>                   </div>                   <div class="container-b">                     <div class="container-c">                         <table border="1"style="width:98%">                           <tr>                             <td width="220" height="100">                               1                             </td>                             <td width="200">                               2                             </td>                             <td width="300">                              <div id="step_form_1" class="order-steps">                               <span>24/01/2016 13:30</span>                               <div>                             </td>                             <td width="120">                               4                             </td>                              <td width="120">                               5                             </td>                           </tr>                         </table>                       </div>                     <div class="side-color">                     </div>                     <div class="tam">                     </div>                   </div>                   <div class="container-b">                     <div class="container-c">                         <table border="1"style="width:98%">                           <tr>                             <td width="220" height="100">                               1                             </td>                             <td width="200">                               2                             </td>                             <td width="300">                              <div id="step_form_1" class="order-steps">                               <span>23/01/2016 13:30</span>                               <div>                             </td>                             <td width="120">                               4                             </td>                              <td width="120">                               5                             </td>                           </tr>                         </table>                       </div>                     <div class="side-color">                     </div>                     <div class="tam">                     </div>                   </div>                   <div class="container-b">                     <div class="container-c">                         <table border="1"style="width:98%">                           <tr>                             <td width="220" height="100">                               1                             </td>                             <td width="200">                               2                             </td>                             <td width="300">                              <div id="step_form_1" class="order-steps">                               <span>18/01/2016 13:30</span>                               <div>                             </td>                             <td width="120">                               4                             </td>                              <td width="120">                               5                             </td>                           </tr>                         </table>                       </div>                     <div class="side-color">                     </div>                     <div class="tam">                     </div>                   </div> 

script

var zxc = 25/01/2016; var asd = 24/01/2016;     $(".container-c table tr td div.order-steps").each(function()     {        $(this).find('span:contains('+zxc+' '+asd+')').length > 0 ?           $(this).show() : $(this).hide();      }); 

if use 1 variable code work's great if put 2 variable, code not working,

this fiddle

your spans have 1 date @ time, need check them separately

//create array of search text var searchtxts = [ "25/01/2016", "24/01/2016" ]; $(".container-c table tr td div.order-steps").each(function() {     //loop through each value    searchtxts.foreach( function(currentvalue){      //check if value contained in span      $(this).find('span:contains('+currentvalue+')').length > 0 ?       $(this).show() : $(this).hide();     } );  }); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -