请你告诉我如何制作div的隐形内容。换句话说,我举例说明我在div中打印一行。但是用户看不到它但是它应该写在div中。但是有些时间对用户可见。
我尝试隐藏可见性但不起作用..
setInterval(function(){
$('#test').append('hi i am div.')
console.log($('#test').html());
},1000);
答案 0 :(得分:0)
添加以下行:
$('#test').hide();
在顶部。
然后添加这部分代码:
setTimeout(function(){
$('#test').show('fade');
},5000);
所以你的完整代码将成为:
$('#test').hide(); // hides the div
setInterval(function () {
$('#test').append('hi i am div.')
console.log($('#test').html());
}, 1000); // adds line to the div
setTimeout(function () {
$('#test').fadeIn();
}, 5000); // shows the div after 5 seconds with fading animation.
答案 1 :(得分:0)
你期待这样吗
<强> HTML 强>
<div id="test"></div>
<input type="button" id="doBlock" value="doBlock">
<强> CSS 强>
#test{
height:100px;
overflow:auto;
border:1px solid red;
width :100%;
display:none;
}
<强>的javascript 强>
setInterval(function(){
$('#test').append('hi i am div.')
//console.log($('#test').html());
},1000);
$( "#doBlock" ).click(function() {
$( "#test" ).css("display", "block");
});
<强>演示强> http://jsfiddle.net/QuETp/6/