Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery显示隐藏_Jquery - Fatal编程技术网

Jquery显示隐藏

Jquery显示隐藏,jquery,Jquery,我有这个代码,但我想隐藏。当窗口加载时测试。 这是切换功能。我没有给css。我希望这很容易,但我不能解决这个问题 <script> $('#toggleDiv').toggle(function() { $('.test').delay(500).animate({ 'opacity': 0, 'right': '-100%' }); $(this).delay(1000).queue(function(n) {

我有这个代码,但我想隐藏。当窗口加载时测试。 这是切换功能。我没有给css。我希望这很容易,但我不能解决这个问题

    <script>
$('#toggleDiv').toggle(function() {
    $('.test').delay(500).animate({
        'opacity': 0,
        'right': '-100%'
    });
    $(this).delay(1000).queue(function(n) {
        $(this).html('show');
        n();
    });
}, function() {
    $('.test').delay(500).animate({
        'opacity': 1,
        'right': '0%'
    });
    $(this).delay(1000).queue(function(n) {
        $(this).html('hide');
        n();
    });
}); 
    </script>
<pre>
<div id="toggleDiv">hide</div>
<div class="test">This secret has been passed down from generation to generation in our family and it reveals how to win a man’s heart.</div>
</pre>
$( ".test" ).toggle();
$("#toggleDiv").click(function(){
    if($("#toggleDiv").text() =="show")
    {
        $("#toggleDiv").text("hide");
    }
    else
        $("#toggleDiv").text("show");
      $( ".test" ).slideToggle( "slow" );
});

$('#toggleDiv')。toggle(函数(){
$('.test')。延迟(500)。设置动画({
“不透明度”:0,
‘正确’:‘100%’
});
$(此).delay(1000).queue(函数(n){
$(this.html('show');
n();
});
},函数(){
$('.test')。延迟(500)。设置动画({
“不透明度”:1,
“右”:“0%”
});
$(此).delay(1000).queue(函数(n){
$(this.html('hide');
n();
});
}); 
html


隐藏
这个秘密在我们家世代相传,它揭示了如何赢得男人的心。

试试下面的方法。。。。这对你有帮助

HTML:

$(".test").hide();
$("#toggleDiv").click(function(){
    if($("#toggleDiv").text() =="show")
    {
        $("#toggleDiv").text("hide");
    }
    else
        $("#toggleDiv").text("show");
      $(".test").toggle("slide", {direction:'right'});
});
$( document ).ready(function() {
   $(".test").hide();
});
<script>
 $(document).ready(function(){
                   $("#toggleDiv").click(function(){
                   $("#test").toggle();
                   });
               });
</script>
CSS:

$(".test").hide();
$("#toggleDiv").click(function(){
    if($("#toggleDiv").text() =="show")
    {
        $("#toggleDiv").text("hide");
    }
    else
        $("#toggleDiv").text("show");
      $(".test").toggle("slide", {direction:'right'});
});
$( document ).ready(function() {
   $(".test").hide();
});
<script>
 $(document).ready(function(){
                   $("#toggleDiv").click(function(){
                   $("#test").toggle();
                   });
               });
</script>
小提琴:

如果要滑动div信息,请尝试以下操作:

Jquery:

$(".test").hide();
$("#toggleDiv").click(function(){
    if($("#toggleDiv").text() =="show")
    {
        $("#toggleDiv").text("hide");
    }
    else
        $("#toggleDiv").text("show");
      $(".test").toggle("slide", {direction:'right'});
});
$( document ).ready(function() {
   $(".test").hide();
});
<script>
 $(document).ready(function(){
                   $("#toggleDiv").click(function(){
                   $("#test").toggle();
                   });
               });
</script>
摆弄:

尝试使用
.hide()
.show()
函数代替。


$(文档).ready(函数(){
$(“#toggleDiv”)。单击(函数(){
$(“#测试”).toggle();
});
});

您提供的代码出了什么问题?您以前使用过吗?请确保您的代码在网站构建后运行。为此,请将
标记放在网站底部,或将代码包装在
$(function(){/*此处的代码*/})中但我想从左到右或从左到右显示它/滑块,你真是太棒了@Pandian