Javascript:切换类添加或删除

时间:2015-12-24 06:42:55

标签: javascript php jquery toggle

我要做的是: 当我点击邮件按钮时,第一个表格将出现并隐藏第二个表格,当按下订阅者按钮时,必须出现第二个表格并隐藏第一个表格。 但我面临的问题就像当我按下第二个按钮时它不会隐藏第一个表

<script>
    function toggle_display(id){
        if(id=='mails'){
            document.getElementById('mails').classList.remove('hidden');
            document.getElementById('subscribers').classList.add('hidden');
        }
        if(id=='subscribers'){
            document.getElementById('mails').classList.add('hidden');
            document.getElementById('subscribers').classList.remove('hidden');
        }
}</script>

<a href="javascript:toggle_display('mails');"><input type="button" class="btn" value="Mails"/></a>
<a href="javascript:toggle_display('subscribers');"><input type="button" class="btn" value="Subscribers"/></a>

        <div class="row well well-lg hidden" id="mails">
               <table class="col-sm-12" border="1px solid black">
               <tr>
                    <th class="col-sm-2">Name</th>
                    <th class="col-sm-2">Email</th>
                    <th class="col-sm-2">Phone</th>
                    <th class="col-sm-2">Subject</th>
                    <th class="col-sm-3">Message</th>
               </tr>
               </table>
          </div>

          <div class="row well well-lg hidden" id="subscribers">
              <table class="col-sm-12" border="1px solid black">
                   <tr>
                      <th class="col-sm-2">ID</th>
                      <th class="col-sm-5">Email</th>
                      <th class="col-sm-3">Action</th>
                   </tr>
              </table>
          </div>

image

1 个答案:

答案 0 :(得分:0)

使用它,它正在工作......

&#13;
&#13;
# re.findall                              
['calendar-days-list2'] 

# soup.find_all
[<td class="calendar-days-list2"     id="pagestructure_0_pagecontent_0_calendar1_2016_1_7_0" width="14%">
<span class="date-number">7</span>
<p>
<img border="0" src="/wac/wacassets/images/icons/h1.gif"/>
<a href="http://www.woodruffcenter.org/Commerce/MuseumAdmissions?     performanceId=86514">Special Exhibitions</a>
        10:00 AM
    </p>
</td>, <td class="calendar-days-list2 prev-next-month"       id="pagestructure_0_pagecontent_0_calendar1_2015_11_29_1" width="14%"></td>]
&#13;
&#13;
&#13;