如何使用if函数隐藏我的网格内的复选框?

时间:2014-12-03 11:18:35

标签: javascript jquery

我在Visual Studio 2013中正在做这个项目,它是一个MVC应用程序。 所以我在这里有这个webgrid:

@gridSensorChoose.GetHtml(
    mode: WebGridPagerModes.All,
    columns:

    gridSensorChoose.Columns(

    gridSensorChoose.Column("SensorID", format: @<text>  <span id="SensorID">@item.SensorID</span>  </text>),

    gridSensorChoose.Column("DeviceID", format: @<text>  <span id="DeviceID">@item.DeviceID</span>  </text>),

    gridSensorChoose.Column("SensorType", format: @<text>  <span id="SensorType">@item.SensorType</span>  </text>),

    gridSensorChoose.Column("SensorName", @Html.Localize("sensorName").ToString(), format: @<text>  <span><label id="SensorName">@item.SensorName</label> </span>  </text>),

    gridSensorChoose.Column("VAL", format: @<text><input type="checkbox" name="val" id="Val"/></text>),

    gridSensorChoose.Column("MIN", format: @<text> <input type="checkbox" name="min" id="Min"/> </text>),

    gridSensorChoose.Column("AVG", format: @<text> <input type="checkbox" name="avg" id="Avg" /> </text>),

    gridSensorChoose.Column("MAX", format: @<text> <input type="checkbox" name="max" id="Max" /> </text>),

    gridSensorChoose.Column("SUM", format: @<text> <input type="checkbox" name="sum" id="Sum" /> </text>),

    gridSensorChoose.Column("INT", format: @<text> <input type="checkbox" name="int" id="Int" /> </text>)

                                ))

现在我想隐藏 ONLY 最后两行的复选框(在我的情况下&#34; SUM&#34;和&#34; INT&#34;),但也离开如果第三行的值(在我的情况下是@ item.SensorType)小于100,则显示的行和culmns(无论它们是否显示)。

我在java脚本中开始做的是:

<script type="text/javascript">
$(function () {
    var tr = $(this).parents('tr:first');
    var SensorType = tr.find("#SensorType").html();
    if (SensorType < 100) {
        $("#Sum").hide();
        $("#Int").hide();
    }
});
</script>

然后我意识到必须完成另一个动作才能让tr工作,因为没有选择任何东西,我只想在页面加载时工作 - 只要显示webgrid。 Cna有人帮忙吗?

这是输出:

<table class="webgrid2-table">
<thead>
    <tr class="webgrid2-header">
        <th scope="col">
            <a href="/PredefinedViews/CreateSensorList?selDeviceID=1&amp;sort=SensorID&amp;sortdir=ASC">SensorID</a>
        </th>
        <th scope="col">
            <a href="/PredefinedViews/CreateSensorList?selDeviceID=1&amp;sort=DeviceID&amp;sortdir=ASC">DeviceID</a>
        </th>
        <th scope="col">
            <a href="/PredefinedViews/CreateSensorList?selDeviceID=1&amp;sort=SensorType&amp;sortdir=ASC">SensorType</a>
        </th>
        <th scope="col">
            Sensor Name
        </th>
        <th scope="col">
            VAL
        </th>
        <th scope="col">
            MIN
        </th>
        <th scope="col">
            AVG
        </th>
        <th scope="col">
            MAX
        </th>
        <th scope="col">
            SUM
        </th>
        <th scope="col">
            INT
        </th>
    </tr>
</thead>
<tbody>
    <tr class="webgrid2-row-style">
        <td class="col1Width">  <span id="SensorID">1</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">10</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Soil Temperature </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-alternating-row">
        <td class="col1Width">  <span id="SensorID">2</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">1</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Soil Moisture na 15cm</label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-row-style">
        <td class="col1Width">  <span id="SensorID">3</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">1</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Soil Moisture na 30cm</label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-alternating-row">
        <td class="col1Width">  <span id="SensorID">4</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">101</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Leaf wetness prvi</label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-row-style">
        <td class="col1Width">  <span id="SensorID">5</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">201</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Ait temperature </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-alternating-row">
        <td class="col1Width">  <span id="SensorID">6</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">202</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Air humidity </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-row-style">
        <td class="col1Width">  <span id="SensorID">7</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">203</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Wind speed </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-alternating-row">
        <td class="col1Width">  <span id="SensorID">8</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">204</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Wind direction </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-row-style">
        <td class="col1Width">  <span id="SensorID">9</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">205</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Precipitation </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-alternating-row">
        <td class="col1Width">  <span id="SensorID">10</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">206</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Solar radiation </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-row-style">
        <td class="col1Width">  <span id="SensorID">51</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">20</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Battery </label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
    <tr class="webgrid2-alternating-row">
        <td class="col1Width">  <span id="SensorID">56</span>  </td>
        <td class="col1Width">  <span id="DeviceID">1</span>  </td>
        <td class="col1Width">  <span id="SensorType">101</span>  </td>
        <td class="col2Width">  <span><label id="SensorName">Leaf wetness drugi</label> </span>  </td>
        <td class="col1Width"><input type="checkbox" name="val" id="Val"></td>
        <td class="col1Width"> <input type="checkbox" name="min" id="Min"> </td>
        <td class="col1Width"> <input type="checkbox" name="avg" id="Avg"> </td>
        <td class="col1Width"> <input type="checkbox" name="max" id="Max"> </td>
        <td class="col1Width"> <input type="checkbox" name="sum" id="Sum" style="display: none;"> </td>
        <td class="col1Width"> <input type="checkbox" name="int" id="Int" style="display: none;"> </td>
    </tr>
</tbody>

2 个答案:

答案 0 :(得分:4)

在您发表评论并发布您的实际html结构后,解决方案完全不同。首先 ID 应该是唯一的。您可以改用类。其次,您可以使用jquery .each()来迭代表格,如下所示:

$("table tr").not(":first").each(function() {
  //chech if sensorType is less than 100 and hide the checkboxes
  if (~~$(this).find(".SensorType").text() < 100) {
    $(this).find(".sum").hide();
    $(this).find(".int").hide();
  }
});
table tr td {
  border: solid 1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="webgrid2-table">
  <thead>
    <tr class="webgrid2-header">
      <th scope="col">
        <a href="/PredefinedViews/CreateSensorList?selDeviceID=1&amp;sort=SensorID&amp;sortdir=ASC">SensorID</a>
      </th>
      <th scope="col">
        <a href="/PredefinedViews/CreateSensorList?selDeviceID=1&amp;sort=DeviceID&amp;sortdir=ASC">DeviceID</a>
      </th>
      <th scope="col">
        <a href="/PredefinedViews/CreateSensorList?selDeviceID=1&amp;sort=SensorType&amp;sortdir=ASC">SensorType</a>
      </th>
      <th scope="col">
        Sensor Name
      </th>
      <th scope="col">
        VAL
      </th>
      <th scope="col">
        MIN
      </th>
      <th scope="col">
        AVG
      </th>
      <th scope="col">
        MAX
      </th>
      <th scope="col">
        SUM
      </th>
      <th scope="col">
        INT
      </th>
    </tr>
  </thead>
  <tbody>
    <tr class="webgrid2-row-style">
      <td class="col1Width"> <span class="SensorID">1</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">10</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Soil Temperature </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-alternating-row">
      <td class="col1Width"> <span class="SensorID">2</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">1</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Soil Moisture na 15cm</label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-row-style">
      <td class="col1Width"> <span class="SensorID">3</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">1</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Soil Moisture na 30cm</label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-alternating-row">
      <td class="col1Width"> <span class="SensorID">4</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">101</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Leaf wetness prvi</label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-row-style">
      <td class="col1Width"> <span class="SensorID">5</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">201</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Ait temperature </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-alternating-row">
      <td class="col1Width"> <span class="SensorID">6</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">202</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Air humidity </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-row-style">
      <td class="col1Width"> <span class="SensorID">7</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">203</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Wind speed </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-alternating-row">
      <td class="col1Width"> <span class="SensorID">8</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">204</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Wind direction </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-row-style">
      <td class="col1Width"> <span class="SensorID">9</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">205</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Precipitation </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-alternating-row">
      <td class="col1Width"> <span class="SensorID">10</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">206</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Solar radiation </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-row-style">
      <td class="col1Width"> <span class="SensorID">51</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">20</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Battery </label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
    <tr class="webgrid2-alternating-row">
      <td class="col1Width"> <span class="SensorID">56</span> 
      </td>
      <td class="col1Width"> <span id="DeviceID">1</span> 
      </td>
      <td class="col1Width"> <span class="SensorType">101</span> 
      </td>
      <td class="col2Width"> <span><label id="SensorName">Leaf wetness drugi</label> </span> 
      </td>
      <td class="col1Width">
        <input type="checkbox" name="val" id="Val">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="min" id="Min">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="avg" id="Avg">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="max" id="Max">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="sum" class="sum" style=";">
      </td>
      <td class="col1Width">
        <input type="checkbox" name="int" class="int" style=";">
      </td>
    </tr>
  </tbody>

答案 1 :(得分:2)

你可以发一个小提琴吗? 也许这可以做到:

$('tr').not(':first').each(function() {
    var $tr = $(this),
        sensorTypeVal = parseInt($tr.find('td').eq(2).find('span').text());
    if(sensorTypeVal < 100) {
        $tr.find('td').eq(-1).find('input').hide();
        $tr.find('td').eq(-2).find('input').hide();
    }
});