Reputation: 537
i trying to hide a div's that not contains a specific value, i have a div that contains a table, inside of table have a span like this:
this is my libraries and css:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ordenes - 99 Minutos</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="static/dashboard/v3/js/jquery-2.1.4.js"></script>
<script src="static/dashboard/v3/js/jquery-ui.js"></script>
<script src="static/dashboard/v3/js/bootstrap.min.js"></script>
<link href="static/dashboard/v3/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="static/dashboard/v3/style.css" type="text/css" />
<link href="static/dashboard/v3/css/jquery-ui.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script>
the code of it:
<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>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>
With Jquery i get the current date, be cause i try to compare the content of the div (date) with the current date, i write a slice to obtain only date witouth time:
var d = $.datepicker.formatDate('dd/mm/yy', new Date());
var e = $("#step_form_1 span").html().slice(0,-6);
I trying to hide div's that not contains a specific date, for example if a div contains 25/01/2016 steel showing and the rest of it hide
Upvotes: 0
Views: 74
Reputation: 8858
You can make use of jquery :contains()
selector to find if a specific element contains the text or not.
$(".container-c table tr td div.order-steps").each(function()
{
$(this).find('span:contains("25/01/2016")').length > 0 ?
$(this).show() : $(this).hide();
});
Example : https://jsfiddle.net/DinoMyte/6x80vabm/3/
Upvotes: 1