如何在Jquery中制作Invisible div内容?

时间:2014-04-19 05:24:48

标签: javascript jquery css

请你告诉我如何制作div的隐形内容。换句话说,我举例说明我在div中打印一行。但是用户看不到它但是它应该写在div中。但是有些时间对用户可见。

我尝试隐藏可见性但不起作用..

http://jsfiddle.net/QuETp/2/

setInterval(function(){

$('#test').append('hi i am div.')
console.log($('#test').html());
},1000);

2 个答案:

答案 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.

Demo

答案 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/