标签: toggle

通过隐藏其他div来在DIV上进行jquery toggle()

我使用以下代码通过单击块标题来切换div.我需要在各个块标题的点击上显示相应的div.这些div也应该自己切换.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
    a { color:#C30; text-decoration:none; }
    #banner { width: 930px; background-color:#666; height: 500px; }
    #banner ul { list-style:none; padding: 40px; }
    #banner ul li { margin: 10px 0 0 0; }
    #banner ul li a { display:inline-block; border:5px solid #fff; background-color:#FC9; padding:10px; font: bold italic 18px Verdana; }
    .sliderContent { border:5px solid #fff; background-color:#FC9; padding:10px; min-height: 150px; display:none; margin-top:5px; }
    .sliderContent a { padding:0 !important; border:none !important; …
Run Code Online (Sandbox Code Playgroud)

jquery function click toggle slidetoggle

1
推荐指数
1
解决办法
3179
查看次数

jQuery淡入/淡出切换方法

if / else在使用切换链接淡入淡出的声明时遇到问题.我可以<div>让它淡入,然而,我似乎无法让它淡出.我有点新鲜ifelse陈述.

你可以在这里看到现场演示.

这是有问题的脚本:

<script type="text/javascript">


    function toggleFader() {
    if ($("#fade_content").is(":hidden")) {
        $("#contentThatFades").animate(
            {
                opacity: "0"    
            },
            600,
            function(){
                $("#fade_content").fadeOut();
            }
        );
    }
    else {
        $("#fade_content").fadeIn(600, function(){
            $("#contentThatFades").animate(
                {
                    opacity: "1"
                },
                600
            );
        });
    }
}


</script>
Run Code Online (Sandbox Code Playgroud)

jquery fade toggle fadeout fadein

1
推荐指数
1
解决办法
1万
查看次数

在单击元素的父级中查找类

我正在尝试在单击元素的父级内找到类.post-info,.toggle-info.现在,页面上的所有.post-info都会切换.我试图只获得一个.post-info来切换它的父容器,.post.

<div class="post">
 <div class="toggle-info">Toggle Btn</div>

 <div class="post-info">
  <p>Toggle this content</p>
 </div>

</div>


$(".toggle-info").click(function () {   
  $(".post-info").animate({ 
    height: "toggle",
    opacity:"toggle"
  }, 520, 'swing');
});
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助!

javascript jquery toggle

1
推荐指数
1
解决办法
288
查看次数

使用jQuery切换检查/取消选中多个复选框列表

检查和取消选中(选择并取消选择全部)复选框列表时遇到两个问题:

  1. 父复选框不会选中/取消选中.
  2. 我只需要选择孩子.

例:

http://jsfiddle.net/TheFiddler/v6wmV/ ,

$(document).ready(function(){
    $('.all').toggle(
        function() {
            $('.check').find('input[type=checkbox]').attr('checked', true);
        },
        function() {
            $('.check').find('input[type=checkbox]').attr('checked', false);
        });
});
Run Code Online (Sandbox Code Playgroud)

现在,我在一个类上有事件,因为这个类由两个复选框列表共享,所以它们都会切换.

checkbox jquery toggle

1
推荐指数
1
解决办法
1万
查看次数

在基本的javascript中悬停和切换

我有一个使用JQuery的简单悬停的以下JavaScript代码:

$('.product_img_link').hover(function(){
  $(this).prev('.hoverProduct').show();
},function(){
  $(this).prev('.hoverProduct').hide();
});
Run Code Online (Sandbox Code Playgroud)

(在div类中找到前一个hoverProduct,并在悬停时显示它并在鼠标移出时将其隐藏).

如何在没有JQuery的情况下使用纯JavaScript编写此代码段?

javascript toggle hover

1
推荐指数
1
解决办法
1038
查看次数

如何使用.toggle与jquery 1.9

我正在尝试使用jquery 1.9的toggle方法,但它已被删除,这里是一个简单的例子来切换div内容 http://jsfiddle.net/Y5pFe/1/ 代码:

<div class="divone"></div>
$(document).ready(function(e) {
$('.divone').toggle(function() {
$(this).text("click one");
}, function() {
$(this).text("click two");
}); 
});
Run Code Online (Sandbox Code Playgroud)

有什么替代方法吗?

toggle jquery-1.9

1
推荐指数
1
解决办法
4475
查看次数

JQuery .each()切换隐藏的元素

对JQuery来说很新,我很难理解.each().

我希望能够点击任何标题,并显示该标题下的段落,然后消失.目前,我只能得到第一段切换.

我的代码是:

<script>
$(document).ready(function(){
  $("h2").click(function(){
    $("#hidden").each(function(){
        $(this).toggle();      
    });
  });
});

</script>

<h2>HEADING 1</h2>
<div id="hidden" style="display:none">
<p>paragraph 1</p>
</div>

<h2>HEADING 2</h2>
<div id="hidden" style="display:none">
<p>paragraph 2</p>
</div>
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助!

each jquery toggle

1
推荐指数
1
解决办法
1万
查看次数

如果选中单选按钮,则切换表单字段的可见性

我最初试图隐藏一组表单字段.然后,如果选择了单选按钮,则显示该组字段.然后,如果取消选择该无线电,则再次隐藏它们.

前两个工作正常(最初隐藏字段,如果选择了无线电则显示它们).但是当取消选择无线电时,我无法让他们再次隐藏.我确定我错过了一些明显的东西,但我无法弄清楚它是什么.

http://jsfiddle.net/C5PMy/

$(document).ready(function() {

toggleFields(); //call this first so we start out with the correct visibility depending on the selected form values

    //Hide the fields initially
    $("#bsd-field-custom-105966-group").hide();
    $("#bsd-field-custom-105967-group").hide();
    $("#bsd-field-custom-105968-group").hide();
    $("#bsd-field-custom-105978").hide();
    $("#bsd-field-custom-105969-group").hide();
    $("#bsd-field-custom-105970").hide();
    $("#bsd-field-custom-105979").hide();
    $("#bsd-field-custom-105971-group").hide();
    $("#bsd-field-custom-105972").hide(); 


//Show the fields only if lodging is required
       $("#custom-105965_0").change(function () {
    toggleFields();
});


});
//this toggles the visibility of the other lodging fields depending on the current     selected value of the "lodging required" field
function toggleFields() {
if ($(("#custom-105965_0").checked)) {

    $("#bsd-field-custom-105966-group").show();
    $("#bsd-field-custom-105967-group").show();
    $("#bsd-field-custom-105968-group").show();
    $("#bsd-field-custom-105978").show(); …
Run Code Online (Sandbox Code Playgroud)

jquery toggle radio-button

1
推荐指数
1
解决办法
1885
查看次数

如何使用Unity Toggle Check Function(选中和未选中)

我正在尝试切换。当我点击切换按钮(如果它处于打开状态,我是指选中的)时,它会关闭一些游戏对象;如果我点击切换按钮(如果它处于关闭状态,我是指未选中的),它会打开一些游戏对象,但是我不知道哪个功能是统一的 toggle.onselecttoggle.onValuesChanged?或其他

public GameObject controlledObject;
public NamesGet nameController;
public Text text;
public Button button;
public Toggle toggle;
private bool deneme;
public void FixedUpdate()
{
    text.text = controlledObject.name;

    if(?????????)
    {
        controlledObject.SetActive(!controlledObject.activeSelf);

    }
}
Run Code Online (Sandbox Code Playgroud)

c# toggle oncheckedchanged unity-game-engine

1
推荐指数
1
解决办法
2万
查看次数

使用SwiftUI,如何使一个Toggle更改另一个Toggle的状态?

我想拥有三个SwiftUI Toggles并具有它们,以便如果其中一个打开,则其他两个关闭。

使用UIKit做这种事情的老方法是didSet {},这不是SwiftUI的正确方法。我不知道是否有必要研究Combine来解决这个问题,从表面上看,这似乎应该很简单。

import SwiftUI

// Mutually exclusive toggle switches: when one toggle is on, the other two should be off. This is a start, where to go from here?

struct Junk: View {

    @State private var isOn1:Bool = true
    @State private var isOn2:Bool = false
    @State private var isOn3:Bool = false

    var body: some View
    {
        VStack
        {
            Toggle("T1", isOn: $isOn1)
            Toggle("T2", isOn: $isOn2)
            Toggle("T3", isOn: $isOn3)
        }
    }
}

struct Junk_Previews: PreviewProvider
{
    static var previews: some …
Run Code Online (Sandbox Code Playgroud)

toggle swift swiftui

1
推荐指数
1
解决办法
348
查看次数