如何使用Jquery如何改变aria-expanded =" false" dom元素的一部分(Bootstrap)? [英] How to use Jquery how to change the aria-expanded="false" part of a dom element (Bootstrap)?

查看:5743
本文介绍了如何使用Jquery如何改变aria-expanded =" false" dom元素的一部分(Bootstrap)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下元素:

<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">

我想使用jquery(或者只是javascript会工作)改变aria-expanded字段切换它在真和假之间。

I want to use jquery (or just javascript would work) to alter the aria-expanded field to toggle it between true and false.

我将如何解决这个问题?

How would I go about this?

谢谢!

推荐答案

您可以使用 .attr()作为部分

$("button").attr("aria-expanded","true");

这篇关于如何使用Jquery如何改变aria-expanded =&quot; false&quot; dom元素的一部分(Bootstrap)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆