Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 ui 刷新“;阿丽亚按";具有标记/样式的UI按钮的数量_Jquery Ui_Checkbox_Label_Uilabel_Checked - Fatal编程技术网

Jquery ui 刷新“;阿丽亚按";具有标记/样式的UI按钮的数量

Jquery ui 刷新“;阿丽亚按";具有标记/样式的UI按钮的数量,jquery-ui,checkbox,label,uilabel,checked,Jquery Ui,Checkbox,Label,Uilabel,Checked,我使用的是,生成的html结构如下所示: <div class="radiocheck ui-buttonset"> <input type="radio" name="radio1" value="1" id="radio0" class="ui-helper-hidden-accessible"> <label for="radio0" aria-pressed="false" class="ui-button ui-widget ui-state-defaul

我使用的是,生成的html结构如下所示:

<div class="radiocheck ui-buttonset">
<input type="radio" name="radio1" value="1" id="radio0" class="ui-helper-hidden-accessible">
<label for="radio0" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left" role="button" aria-disabled="false">
    <span class="ui-button-text">Sobre</span>
</label>
<input type="radio" name="radio1" value="2" id="radio1" class="ui-helper-hidden-accessible">
<label for="radio1" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only" role="button" aria-disabled="false">
    <span class="ui-button-text">Politica</span>
</label>
<input type="radio" name="radio1" value="3" id="radio2" class="ui-helper-hidden-accessible">
<label for="radio2" aria-pressed="true" class="ui-button ui-widget ui-state-default ui-button-text-only" role="button" aria-disabled="false">
    <span class="ui-button-text">Outros</span>
</label>
<input type="radio" name="radio1" value="4" id="radio3" class="ui-helper-hidden-accessible">
<label for="radio3" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right" role="button" aria-disabled="false">
    <span class="ui-button-text">Promocoes</span>
</label>

索夫雷
政客
奥特罗斯
宣传片

当我将“aria pressed”属性更改为“true”时,按钮根本不会更改。。。我试过这样做,但没有成功:

var myhappyidtest=2

$('.radiocheck输入')。每个(函数(i){ if(myhappyidtest==$(this.val()){ $(this).next('label').attr('aria-pressed','true'); } });

我看到在按钮盒中,可以刷新。 但我不知道在这种情况下如何使用标签

有人有主意吗

我只需将“ui-state-active”类添加到元素中,它就可以工作了

var myhappyidtest = 2;

$('.radiocheck input').each(function(i){
    if(myhappyidtest == $(this).val()){
        $(this).next('label').attr('aria-pressed', 'true');
        $(this).next('label').addClass('ui-state-active');
    }else{
        $(this).next('label').attr('aria-pressed', 'false');
        $(this).next('label').removeClass('ui-state-active');
    }
});
更新

根据@Gnought和@Vladimir的建议,并使用@Vladimir的方法,以下是对这个问题的最新答案:

var myhappyidtest = 2;

$('#format input[value="' + myhappyidtest + '"]').attr('checked', true).button('refresh');
由于示例的原始链接已关闭,因此我在这里制作了一个示例:


谢谢您的建议。

实际上,您应该让jquery ui进行样式设置:

$(this).attr('checked', false);
$(this).button('refresh');

我认为aria属性专门用于辅助技术,以帮助向残疾用户传达信息。我不相信这对按钮的外观有任何影响。谢谢克里斯!我找到了解决办法。。。太简单了!=)我只是将ui状态活动类添加到元素中,然后将aria pressed设置为true,它就可以工作了!没问题,快乐编码;)aria按下和ui状态激活受JQuery内部更改的影响。我认为不建议采用这种方法。
$(this).attr('checked', false);
$(this).button('refresh');