Javascript(下拉功能)与TR标签

时间:2016-01-19 21:15:14

标签: javascript html drop-down-menu html-table mapping

我想美化我古老的德语/英语商业词典。 我想,为了获得更好的视图,我只会通过单击节标题来显示和显示描述。

所以我在下面找到了Javascript代码。 现在,我的一个大问题是,单元格在Javascript映射之后不再需要像#34; header2"这样的所需设计。

愿任何人可以提供帮助,或者任何人都可以向我推荐更好的东西吗?

我的代码:



function spoil(id) {
  if (document.getElementById) {
    var divid = document.getElementById(id);
    divid.style.display = (divid.style.display == 'block' ? 'none' : 'block');
  }
}

.itabelle {
  border: 1pt solid black;
  font-size: 12pt;
  background-color: #cccccc;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.ttype1 {
  border-bottom: 1px dashed #000000;
  color: #000000;
  letter-spacing: 2px;
  font-size: 16pt;
  font-style: normal;
  font-family: Arial;
  width: 50%;
  text-align: center;
  font-weight: bold;
}
.ttype2 {
  border-bottom: 0px dashed #000000;
  color: #000000;
  letter-spacing: 2px;
  font-style: normal;
  font-family: Arial;
  width: 50%;
  text-align: center;
  font-weight: bold;
  font-size: 13pt;
}
.ttype3 {
  border: 1px solid #000000;
  width: 50%;
}

<table class="itabelle">
  <tbody>
    <tr>
      <td class="ttype1">german</td>
      <td class="ttype1">englisch</td>
    </tr>
    <tr>
      <td colspan="2" rowspan="1">
        <br>
      </td>
    </tr>
    <tr>

      <td class="ttype2" colspan="2" rowspan="1"><span style="cursor: pointer;" onclick="spoil('id1');">header1<br>
    
    </span>
      </td>
    </tr>

    <tr id="id1" style="display: none;">
      <td class="ttype3">lexicon article for header1 (german)</td>

      <td class="ttype3">lexicon article for header1 (english)</td>
    </tr>

    <tr>
      <td class="ttype2" colspan="2" rowspan="1">Header2 (without javascript mapping)</td>
    </tr>

    <tr>
      <td class="ttype3">lexicon article for header2 (german)</td>
      <td class="ttype3">lexicon article for header2 (english)</td>
    </tr>


  </tbody>
</table>
&#13;
&#13;
&#13;

提前抱歉混乱了html4 / 5代码。

1 个答案:

答案 0 :(得分:0)

<?php $matches = []; if (preg_match('/g\.load\(\{ajaxURL:"([^"]*)",[^})]*,divId:"listing-provided-by-module"/s', $string, $matches)) { $url = $matches[1]; } else { // No match found. } 的正常display样式为<tr>。但是,当您显示行时,您的Javascript会将其设置为table-row。将其更改为使用block

table-row
function spoil(id) {
  if (document.getElementById) {
    var divid = document.getElementById(id);
    divid.style.display = (divid.style.display == 'table-row' ? 'none' : 'table-row');
  }
}
.itabelle {
  border: 1pt solid black;
  font-size: 12pt;
  background-color: #cccccc;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.ttype1 {
  border-bottom: 1px dashed #000000;
  color: #000000;
  letter-spacing: 2px;
  font-size: 16pt;
  font-style: normal;
  font-family: Arial;
  width: 50%;
  text-align: center;
  font-weight: bold;
}
.ttype2 {
  border-bottom: 0px dashed #000000;
  color: #000000;
  letter-spacing: 2px;
  font-style: normal;
  font-family: Arial;
  width: 50%;
  text-align: center;
  font-weight: bold;
  font-size: 13pt;
}
.ttype3 {
  border: 1px solid #000000;
  width: 50%;
}