jQuery与display的显隐测试实例页面
代码:
CSS代码:
.table-cell{display:table-cell; background-color:#f0f3f9;}
.display-display{margin:1em 0;}
HTML代码:
<p id="tableCell" class="table-cell">这是一段<code>display:table-cell</code>属性下的文字,点击下面的按钮显隐切换。</p>
<p id="displayDisplay" class="display-display"></p>
<button id="button" type="button">点击我</button>
JS代码:
var funShowDisplay = function() {
$("#displayDisplay").text("现在的display属性值是:" + $("#tableCell").css("display"));
};
funShowDisplay();
$("#button").click(function() {
$("#tableCell").toggle();
funShowDisplay();
});
效果:
这是一段display:table-cell属性下的文字,点击下面的按钮显隐切换。