【问题标题】:Change table (spliced image) onclick更改表(拼接图像)onclick
【发布时间】:2011-10-10 10:14:08
【问题描述】:

我是 jquery 的新手,所以如果这很简单,我很抱歉。我环顾四周,没有找到任何我想要的东西。我有 3 张桌子是拼接的图像。每个表都有一个 id。当有人点击表格中的图像时,我希望表格更改为另一个也有 id 的表格。我不知道该怎么做。我希望这是有道理的。

我希望能够更改整个表格,而不是理想地更改每个单独的图像。

<table id="norm">
<tr><td>
<!-- images -->
<!-- clickable image -->
<!-- images-->
</td></tr>
</table>


<table id="chang1">
<tr><td>
<!-- images -->
<!-- clickable image -->
<!-- images-->
</td></tr>
</table>


<table id="chang2">
<tr><td>
<!-- images -->
<!-- clickable image -->
<!-- images-->
</td></tr>
</table>

这是我想要做的,但在 PHP 中:

if($_GET['imtype']=='norm'){
  //show id='norm' table
}else{
  if($_GET['imtype']=='chang1'){
    //show id='chang1' table
  }else{
    if($_GET['imtype']=='chang2'){
      //show id='chang2' table
    }  
  }
}

【问题讨论】:

    标签: php jquery html-table


    【解决方案1】:

    变化部分很好

    $('#chang1').show();
    $('#oldtable').hide();
    

    这可以解决问题,但在条件下我并没有完全得到你想要做的事情。 哪些图像应该重定向到哪个表?

    那么这会有所帮助

    function ShowTable(tableId)
    {
        $('table').hide();
        $('#' + tableId).show();
    }
    

    您只需在链接上添加 href="javascript:ShowTable('yourtableid')"

    【讨论】:

    • 每张图片应该有 3 个链接,根据点击的链接加载 3 个表格中的 1 个。所以 id="norm" 表中有 3 个图像链接,它们指向 id="norm" 表、id="chang1" 表和 id="chang2" 表。 id="chang1" 表和 id="chang2" 表有相同的东西。这更有意义吗?
    猜你喜欢
    • 1970-01-01
    • 2020-12-16
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    • 2022-01-06
    • 1970-01-01
    相关资源
    最近更新 更多