我正在使用带有样式的 UI 按钮 - Like | 乙| 我 | 你 | 在这个示例页面中,生成的 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 input').each(function(i){
if(myhappyidtest == $(this).val()){
$(this).next('label').attr('aria-pressed', 'true');
}
});
我看到在按钮情况下,可以refresh。但我不知道在这种情况下如何使用标签执行此操作。
有人有想法吗?