Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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
Css 单选按钮未动态应用样式_Css_Jquery Mobile_Radio Button - Fatal编程技术网

Css 单选按钮未动态应用样式

Css 单选按钮未动态应用样式,css,jquery-mobile,radio-button,Css,Jquery Mobile,Radio Button,每次用户访问选项卡菜单时,我都尝试刷新单选按钮列表。首次访问样式设置是可以的,但它们的行为类似于复选框,在单击其他单选按钮时无法取消选中 我试着把refresh()方法,但它仍然不起作用 你可以在屏幕上看到演示 有什么建议吗?谢谢你 $('.export_tab').click(function(){ $("#radios_wrapper").children().remove(); //Remove all previous radio buttons for(var i in

每次用户访问选项卡菜单时,我都尝试刷新单选按钮列表。首次访问样式设置是可以的,但它们的行为类似于复选框,在单击其他单选按钮时无法取消选中

我试着把
refresh()方法,但它仍然不起作用

你可以在屏幕上看到演示

有什么建议吗?谢谢你

$('.export_tab').click(function(){
    $("#radios_wrapper").children().remove(); //Remove all previous radio buttons
    for(var i in localStorage) //Looping through the localStorage
        {
            dataIndex = JSON.parse(localStorage[i]).index;
            dataName = JSON.parse(localStorage[i]).name;
                    //Then insert a new one
            $("#radios_wrapper").append('<input type="radio" value="'+dataIndex+'" name="'+dataIndex+'" id="radio'+dataIndex+'"/><label for="radio'+dataIndex+'">'+dataName+'</label>');
        }
});
$('.export_选项卡')。单击(函数(){
$(“#radios_wrapper”).children().remove();//删除以前的所有单选按钮
for(localStorage中的var i)//在localStorage中循环
{
dataIndex=JSON.parse(localStorage[i]).index;
dataName=JSON.parse(localStorage[i]).name;
//然后插入一个新的
$(“#radios_wrapper”).append(“”+dataName+“”);
}
});
这是HTML

<div data-role="fieldcontain">
     <fieldset data-role="controlgroup" id='radios_wrapper'>

     </fieldset>
</div>

单选按钮需要相同的名称才能成为一个组。因此:

'<input type="radio" value="'+dataIndex+'" name="'+dataIndex+'"/>'
“”
这不是正确的方法。要分组的所有收音机的名称应相同。应该是:

'<input type="radio" value="'+dataIndex+'" name="allTheSame"/>'
“”
以下是您的更新


要告诉jQuery重画,请使用触发器函数,如
.append('whatever').trigger('create')
。更新。

提供演示:,等等。给你。我已经试过了。它仍然不起作用。请看这里的演示@PakinaiKamolpus:你的小提琴不符合我说的。看我的最新消息。好的。但是他们仍然没有采用这种风格。风格?我在你的帖子或小提琴上看不到任何样式代码。我明白了。我更新了我的答案和你的小提琴。也许这会有帮助。