如果包含不同的变量值,如何隐藏div

时间:2016-01-25 19:26:51

标签: javascript jquery html

我试图隐藏不包含特定值的div,我有一个包含表格的div,表格内部有这样的跨度:

这是我的库和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>

enter image description here

它的代码:

<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>

使用Jquery我得到当前日期,因为我尝试将div(日期)的内容与当前日期进行比较,我写一个切片以获得只有时间的日期:

var d = $.datepicker.formatDate('dd/mm/yy', new Date());

var e = $("#step_form_1 span").html().slice(0,-6);

我试图隐藏不包含特定日期的div,例如,如果div包含25/01/2016钢铁显示而其余部分隐藏

1 个答案:

答案 0 :(得分:1)

您可以使用jquery return reply('Here is token') .type('text/html') .header('X-authorization', token) .code(200); 选择器来查找特定元素是否包含文本。

:contains()

示例:https://jsfiddle.net/DinoMyte/6x80vabm/3/