【发布时间】:2023-03-14 03:23:01
【问题描述】:
我有以下 HTML 代码,使用 Bootstrap:
<div class="progress">
<div class="progress-bar progress-bar-striped active" id="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
</div>
</div>
我希望style="width: 0" 增加到 100%。我尝试使用下面的代码作为测试,但没有任何反应。
<head>
<title>Verifying Oracle database...</title>
<script src="ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
$("#progress-bar").css("width", "50%");
$("#progress-bar").attr("aria-valuenow", "50%");
});
</script>
</head>
有人可以帮助实现这一进展吗?
提前致谢。
【问题讨论】:
-
您在加载 DOM 元素之前运行该脚本。您需要将其包装在
$(document).ready()中或将脚本放在<body>的末尾 -
@Brennan,感谢您的回答。我放在
<body>的末尾,但也没有用。 :(
标签: javascript jquery twitter-bootstrap