刷新“aria-pressed”带有标记/样式的 UI 按钮
我正在使用 UI 按钮,样式如下|乙|我|你|在这个示例页面中,生成的 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 输入').each(function(i){
if(myhappyidtest == $(this).val()){
$(this).next('label').attr('aria-pressed', 'true');
}
});
我发现在按钮情况下,可以刷新。 但我不知道如何在这种带有标签的情况下做到这一点。
有人有主意吗?
I'm using the UI buttons with style - Like | B | I | U | in this example page, and the html structure generated look like this:
<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>
When I change the "aria-pressed" propertie to "true", the button doesn't change at all... I tryed this way, but it didn't work:
var myhappyidtest = 2;$('.radiocheck input').each(function(i){ if(myhappyidtest == $(this).val()){ $(this).next('label').attr('aria-pressed', 'true'); } });
I saw that in button cases, it's possible to refresh.
But I don't have idea on how to do this in this case with label.
Someone have an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只需将“ui-state-active”类添加到元素中就可以了!
更新
按照@Gnought和@Vladimir的建议,并使用@Vladimir的方法,这里是这个问题的更新答案:
由于示例的原始链接已关闭,我在这里做了一个示例:http://jsfiddle.net/psycocandy/8SpGd/1/
感谢您的建议。
I just add the "ui-state-active" class to the element and it works!
UPDATE
As suggested by @Gnought and @Vladimir, and using the approach of @Vladimir, here's an updated answer to this question:
As the original link of the example is off, I've made an example here: http://jsfiddle.net/psycocandy/8SpGd/1/
Thank you for the suggestions.
实际上,你应该让 jquery ui 来做样式:
Actually, you should let jquery ui do the styling: