用symfony隐藏树枝中的表格行 - javascript

我正在开始编码。我正在使用Symfony 3.3
我想用复选框隐藏(并显示)表上的a或某些特定行。
我尝试使用javascript和jquery。我希望隐藏的行保持隐藏状态。
我不知道该怎么做。这是我的树枝

{% block body %}

    <div class="container">
        <h3>List of products</h3>

        <table class="table table-striped">
    <thead>
    <tr>
        <th>Product</th>
        <th>Description</th>
        <th>Size</th>
        <th>Charges</th>
        <th>Price</th>
        <th>Actions</th>
        <th>Desactivation</th>

    </tr>
    </thead>

    <tbody>
    {% for catalogue in catalogues %}
    <tr class="table">

        <td>{{ catalogue.product}} </td>
        <td>{{ catalogue.description }} </td>
        <td>{{ catalogue.size}} </td>
        <td>{{ catalogue.charge }} </td>
        <td>{{ catalogue.price }}</td>
        <td>
            <a href="{{ path('catalogue_list_edit', { 'id': catalogue.id }) }}"><span class="glyphicon glyphicon-edit"></span></a>
            <a href="{{ path('catalogue_list_delete', { 'id': catalogue.id }) }}"><span class="glyphicon glyphicon-remove"></span></a>
        </td>
            <td><input type="checkbox" name="boutton35"  value="Desactivation"  />
      </td>

    </tr>

    {% else %}
    {% endfor %}

    </tbody>
        </table>

{% endblock %}

参考方案

$('.hideshow').on('click',function(){
  let cls = $(this).attr("data-id")
  if ( $('#'+cls).css('display') == 'none' ){
    $('.table tbody').find('#'+cls).show();
  }else{
    $('.table tbody').find('#'+cls).hide();
  }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <h3>List of products</h3>

  <div class="buttons">
    <button type="button" data-id="tr1" class="hideshow">Hide/Show Row 1</button>
    <button type="button" data-id="tr2" class="hideshow">Hide/Show Row 2</button>
    <button type="button" data-id="tr3" class="hideshow">Hide/Show Row 3</button>
  </div>
  <table class="table table-striped">
    <thead>
      <tr>
        <th>Product</th>
        <th>Description</th>
        <th>Size</th>
        <th>Charges</th>
        <th>Price</th>
        <th>Actions</th>
        <th>Desactivation</th>
      </tr>
    </thead>

    <tbody>
      <tr id="tr1">
        <td>Product </td>
        <td>Description </td>
        <td>Size </td>
        <td>Charges </td>
        <td>Price</td>
        <td>
          <a href="#">Edit</a>
          <a href="#">Remove</a>
        </td>
        <td><input type="checkbox" name="boutton35" value="Desactivation" />
        </td>
      </tr>
      <tr id="tr2">
        <td>Product </td>
        <td>Description </td>
        <td>Size </td>
        <td>Charges </td>
        <td>Price</td>
        <td>
          <a href="#">Edit</a>
          <a href="#">Remove</a>
        </td>
        <td><input type="checkbox" name="boutton35" value="Desactivation" />
        </td>
      </tr>
      <tr id="tr3">
        <td>Product </td>
        <td>Description </td>
        <td>Size </td>
        <td>Charges </td>
        <td>Price</td>
        <td>
          <a href="#">Edit</a>
          <a href="#">Remove</a>
        </td>
        <td><input type="checkbox" name="boutton35" value="Desactivation" />
        </td>
      </tr>
    </tbody>
  </table>

将Web用户控件添加到页面时,asp按钮onclick不会触发 - javascript

我正在使用使用Visual Studio模板创建的Web表单应用程序。模板具有一个内容占位符,该占位符被访问的任何页面的内容替换。有问题的页面有几个服务器控件,例如文本框,标签和按钮。当我单击我的更新按钮时,它可以正常工作,这些值会回传并更新数据库。我想在所有子页面上创建通用的登录提示。我的导航栏(位于我的母版页中)具有引导程序设置。我在导航栏中添加了一个下…

Telerik单选按钮所需的字段验证器 - javascript

如何设置Telerik单选按钮所需的字段验证器?我想在按钮单击“ BtnSave”上设置必填字段验证器吗?请帮忙!<telerik:RadButton ID="radio_male" runat="server" ToggleType="Radio" AutoPostBack="fa…

表单不提交或按钮提交不起作用 - javascript

据我所知,此代码必须有效,但是我编码时却无效问题在于该表单未提交。我该如何解决?选中时,我什至没有得到复选框的值。<table id="example" class="display" cellspacing="0" width="100%"> <thead&g…

如何在Django中进行多次更新? - javascript

我试图通过选中复选框然后按“更新”按钮来在django中进行多次更新。这是我的view.pydef update_kel_stat(request, id, kelid): if request.method == "POST": cursor = connection.cursor() sql = "UPDATE keluar…

在PHP文件中调用javascript函数并在加载HTML文件之后? - javascript

我需要在我的php中调用js函数,但无法正常工作。有人可以告诉我我在做什么错吗?我该如何轻松地做到这一点?谢谢!我有三个文件:  mail.php负责发送$ _POST的内容(工作正常)。我调用我的javascript函数来切换模式,具体取决于邮件是否已发送。 <? ... $response = $sendgrid->send($email);…