Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.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
Javascript 获取值数据切换单选按钮_Javascript_Jquery_Html - Fatal编程技术网

Javascript 获取值数据切换单选按钮

Javascript 获取值数据切换单选按钮,javascript,jquery,html,Javascript,Jquery,Html,使用data toggle=“wizard radio”从引导单选按钮字段获取值时遇到问题 $('[data toggle=“wizard radio”]')。单击(函数(){ wizard=$(this).closest('.wizard-card'); wizard.find('[data toggle=“wizard radio”]')。removeClass('active'); $(this.addClass('active'); $(向导).find('[type=“radio”]

使用data toggle=“wizard radio”从引导单选按钮字段获取值时遇到问题

$('[data toggle=“wizard radio”]')。单击(函数(){
wizard=$(this).closest('.wizard-card');
wizard.find('[data toggle=“wizard radio”]')。removeClass('active');
$(this.addClass('active');
$(向导).find('[type=“radio”]')。removeAttr('checked');
$(this.find('[type=“radio”]').attr('checked','true');
});

家
Eengezinswoning

我相信您希望将材质图标与引导一起使用

  • 将其置于
    标签中:

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.materialdesignicons.com/2.1.19/css/materialdesignicons.min.css" rel="stylesheet">
    
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    
    .mdi::之前{
    字体大小:24px;
    线高:14px;
    }
    .btn.mdi::之前{
    位置:相对位置;
    顶部:4px;
    }
    .btn xs.mdi::之前{
    字号:18px;
    顶部:3px;
    }
    .btn sm.mdi::之前{
    字号:18px;
    顶部:3px;
    }
    .下拉菜单.mdi{
    宽度:18px;
    }
    .下拉菜单.mdi::before{
    位置:相对位置;
    顶部:4px;
    左:-8px;
    }
    .nav.mdi::之前{
    位置:相对位置;
    顶部:4px;
    }
    .navbar.navbar toggle.mdi::before{
    位置:相对位置;
    顶部:4px;
    颜色:#FFF;
    }
    .breadcrumb.mdi::之前{
    位置:相对位置;
    顶部:4px;
    }
    .面包屑a:悬停{
    文字装饰:无;
    }
    .面包屑a:悬停范围{
    文字装饰:下划线;
    }
    .alert.mdi::之前{
    位置:相对位置;
    顶部:4px;
    右边距:2px;
    }
    .input group addon.mdi::before{
    位置:相对位置;
    顶部:3px;
    }
    .navbar brand.mdi::之前{
    位置:相对位置;
    顶部:2个;
    右边距:2px;
    }
    .list组项.mdi::之前{
    位置:相对位置;
    顶部:3px;
    左:-3px
    }
    /*无线电*/
    输入,
    标签{
    字体:继承;
    字号:900
    }
    雷德先生{
    显示:无;
    }
    标签{
    显示:内联块;
    宽度:100%;
    身高:100%;
    }
    #关,,
    #在,,
    #站着,
    #踢{
    显示:无
    }
    #在……之前{
    字体系列:“材质设计图标”;
    内容:'\F521';
    }
    #踢:之前{
    字体系列:“材质设计图标”;
    内容:“\F82B”;
    }
    #在……之后{
    字体系列:“Segoe用户界面符号”;
    内容:'\a0ON';
    }
    #踢……之后{
    字体系列:“Segoe用户界面符号”;
    内容:'\a0KIA!';
    }
    #在,,
    #踢{
    显示:内联块;
    }
    #关闭::之前{
    字体系列:“材质设计图标”;
    内容:'\F522';
    }
    #站在……前面{
    字体系列:“材质设计图标”;
    内容:'\F64B';
    }
    #结束后{
    字体系列:“Segoe用户界面符号”;
    内容:'\a0OFF';
    }
    #站在…后面{
    字体系列:“Segoe用户界面符号”;
    内容:'\a0…';
    }
    #rad0:已选中~#on,
    #雷达:检查~#踢{
    显示:内联块;
    }
    #rad0:已选中~#关闭,
    #雷达:检查~#站着{
    显示:无;
    }
    #rad1:已选中~#关闭,
    #radB:已检查~#支架{
    显示:内联块;
    }
    #rad1:已选中~#on,
    #radB:检查~#踢{
    显示:无;
    }
    #出去{
    颜色:红色;
    字号:900;
    }
    
    平衡
    当心!
    危险!
    放射组列表
    
    只需尝试使用活动类获取值,如:

    $('.choice.active input').val()
    

    能否添加包含向导卡类的html片段?您的代码至少在两个方面无效:1<代码>标签
  • 元素不能包含块级元素,如
    div
    ;2.当我单击“运行代码段”时,我立即得到一个错误。向导卡在哪里?为什么您要再次搜索
    [data toggle=“wizard radio”]
    ,而不是使用
    ?为什么要删除激活的,然后在同一代码中再次添加?然后你对
    收音机做了同样的事
    ?你的代码毫无意义。此外,您的HTML无效,因为如Mike所述,
    标签
    标记不能包含
    div
    。请解释您正在尝试做什么,以便我们可以帮助您。感谢您的快速回复!我想使用图像而不是单选按钮,这就是为什么我添加了。当时不知道你不能用。.wizard卡位于上部。我没有使用javascript(仅html和php)的经验,请尝试
    $('[data toggle=“wizard radio”]')
    $('input[type=“radio”]')
    </button>
    
    $('.choice.active input').val()