小编Jas*_*faa的帖子

jQuery tablesorter问题 - 用rowspan排序

我在桌子上使用jQuery tablesorter.没有rowspan,表格排序很好,但是当我添加时rowspan,排序会破坏我的表格布局.

这是一些示例代码:

<table cellspacing="1" class="tablesorter">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Age</th>
      <th>Country</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Peter</td>
      <td>28</td>
      <td rowspan="2" style="vertical-align:middle">AAA</td>
    </tr>
    <tr>
      <td>John</td>
      <td>33</td>
    </tr>
    <tr>
      <td>Clark</td>
      <td>18</td>
      <td>BBB</td>
    </tr>

    <tr>
      <td>Bruce</td>
      <td>22</td>
      <td>CCC</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
$(".tablesorter").tablesorter({});    
Run Code Online (Sandbox Code Playgroud)

没有点击排序,我的表看起来像这样:

没有排序

当我点击国家标题时,表格变得非常乱码

随着排序

jquery tablesorter html-table

8
推荐指数
1
解决办法
1495
查看次数

获取选择ID onchange Jquery

在我的应用程序中,我试图在访问onchange函数时获取选择框的id.这里有2个选择框,都指向相同的功能检查.如果选择这两个选择框,我可以获得选择框的ID.示例1和示例2.

<select id="example1" onchange='check()'>
    <option value="1">one</option>
    <option value="2">two</option>
    <option value="3">three</option>
    <option value="4">four</option>
</select>Example 2 :
<select id="example2" onchange='check()'>
    <option id="1">one</option>
    <option id="2">two</option>
    <option id="3">three</option>
    <option id="4">four</option>
</select>
Run Code Online (Sandbox Code Playgroud)

我的Jquery函数,但它只获得第一个选择框的id.

<script>
function check(){
 var id = $('select').attr('id');
 alert(id);
}
</script>
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
1
解决办法
1万
查看次数

同时循环并排表

在while循环中,它创建了一个标题和图像链接的列表,我想像下面的图像一样并排显示它.每个标题shold来自新列和图像应该在每个类别下.并且只有3行. 在此输入图像描述

这是我的代码:

<table> 
    <tr>
        <th>Heading 1</th>
        <th>Heading 2</th> 
        <th>Heading 3</th>
    </tr> 
    <?php
        //example array $images = array('Image 1', 'Image 2', 'Image 3', 'Image 4', 'Image 5', );
        for ($i=0; $i<count($images); $i++) { ?> 
        <tr> 
            <td>
            <?php echo $images[$i]; ?></td>
            <td><?php echo $i<3?$images[$i]:''; ?></td>
            <td><?php echo $i<1?$images[$i]:''; ?></td>
        </tr> <?php } ?>
</table>
Run Code Online (Sandbox Code Playgroud)

php while-loop

2
推荐指数
1
解决办法
451
查看次数

标签 统计

jquery ×2

html-table ×1

php ×1

tablesorter ×1

while-loop ×1