【问题标题】:HTML Table creation - when an event as occuredHTML 表创建 - 发生事件时
【发布时间】:2013-12-10 17:53:17
【问题描述】:

我创建了一个 HTML 表格。只有在单击按钮时,我才需要显示此表。有人可以建议如何实现这一目标吗?

问候 吉里

【问题讨论】:

  • 用什么? JavaScript 还是 asp.net ?
  • 您使用什么语言? php? JavaScript? html?

标签: html-table


【解决方案1】:

您可以使用 jquery 并附加一个处理程序。 例如 在html中:

<a class="button-link" href="javascript:void(0);">link</a>
<table class='hidden-table'>
<tr>
<th>id</th><th>name</th>
</tr>
<tr>
<td>1</td><td>Mr Awesome</td>
</tr>
</table>

在css中:

.hidden-table{
   display:none;
}

在 js/jquery 中

$('.button-link').on('click',function(){
    $('.hidden-table').show()
})

先使用 css 隐藏表格,然后单击链接将显示表格。

【讨论】:

  • 请接受作为答案,这样如果其他人注意相同的问题,他们就会知道这个问题有答案。谢谢,祝你有美好的一天。
【解决方案2】:

你可以使用 Jquery,从这里http://jquery.com/download/

安装后,您可以使用以下语法:

$('#idofthebutton').click(function(){


$('#idofthetable').toggle();


});

【讨论】:

    猜你喜欢
    • 2010-10-18
    • 2023-03-03
    • 2016-03-17
    • 2011-06-04
    • 2018-03-24
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多