Jquery toggle设置属性为display: table而不是block
jquery toggle sets property as display : table instead of block
我在玩一些代码时遇到了以下情况,其中toggle on a table标签将属性样式设置为"display: table"而不是"display: block"。(需要使用firebug等开发人员工具才能看到这种行为)。根据我的理解,toggle只将显示设置为'none'或'block'。
代码如下:
<button class="read">Toggle Table</button>
<table class="displayReviews"></table>
<br>
<button class="write">Toggle Form</button>
<form class="writeForm">Form</form>
<script>
$('button').click(function() {
if($(this).attr("class") == "read")
{
$(".displayReviews").toggle();
}
else if($(this).attr("class") == "write")
{
$(".writeForm").toggle();
}
});
</script>
<style>
.writeForm
{
display:none;
}
.displayReviews
{
display:none;
}
</style>
jsfiddle: https://jsfiddle.net/thL7Lyff/
谁能告诉我为什么会这样?<script>
$('button').click(function() {
if($(this).attr("class") == "read")
{
if($(".displayReviews").css("display") == "none"){
$(".displayReviews").css("display", "block");
} else {
$(".displayReviews").css("display", "none");
}
}
else if($(this).attr("class") == "write")
{
$(".writeForm").toggle();
}
});
</script>
相关文章:
- Jquery - table.row(tr) is undefined
- javascript, ajax, table, colour
- jQuery parent() in table
- click-cell.bs.table是如何工作的
- 在javascript中将样式显示从none更改为block
- onclick for table TD
- Javascript -> CSS (display:none to display:block)
- AppendChild Form / Table [Javascript/Html/PHP]
- javascript if block 的奇怪行为
- Javascript: Output table
- onRowClick for react-bootstrap-table
- Google Fusion Table Javascript UPDATE Query?
- jquery .删除整个 li 或 table 元素后
- JQuery Click on Table
- AngularJS translate table
- CSS styling of <UL> as table
- Bootstrap Table
- 如何从SQL API代码迁移到Google Fusion Table API v1
- Jquery toggle设置属性为display: table而不是block
- jQuery toggle table元素:use "display: block"而不是"