gpt4 book ai didi

JavaScript 问题 |进度条

转载 作者:行者123 更新时间:2023-12-03 09:41:08 25 4
gpt4 key购买 nike

我在这里找到了这个http://www.codeply.com/go/bp/wj9gWh8ulj我试图通过应用这些代码来了解有关 javascript 和 jquery 的更多信息,但是在实现此代码时遇到了一个错误,即进度条和继续按钮由于某种我不知道的原因不起作用。

<html>
<head>
<script src="js/jquery.min.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">

<script src="js/bootstrap.min.js"></script>
<script>
$('.next').click(function(){
var nextId = $(this).parents('.tab-pane').next().attr("id");
$('[href=#'+nextId+']').tab('show');
return false;
})

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
//update progress
var step = $(e.target).data('step');
var percent = (parseInt(step) / 5) * 100;

$('.progress-bar').css({width: percent + '%'});
$('.progress-bar').text("Step " + step + " of 5");
//e.relatedTarget // previous tab
})

$('.first').click(function(){
$('#myWizard a:first').tab('show')
})
</script>
</head>

<body>

<div class="container" id="myWizard">

<h3>Bootstrap Wizard</h3>

<hr>

<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="1" aria-valuemin="1" aria-valuemax="5" style="width: 20%;">
Step 1 of 5
</div>
</div>

<div class="navbar">
<div class="navbar-inner">
<ul class="nav nav-pills">
<li class="active"><a href="#step1" data-toggle="tab" data-step="1">Step 1</a></li>
<li><a href="#step2" data-toggle="tab" data-step="2">Step 2</a></li>
<li><a href="#step3" data-toggle="tab" data-step="3">Step 3</a></li>
<li><a href="#step4" data-toggle="tab" data-step="4">Step 4</a></li>
<li><a href="#step5" data-toggle="tab" data-step="5">Step 5</a></li>
</ul>
</div>
</div>
<div class="tab-content">
<div class="tab-pane fade in active" id="step1">

<div class="well">

<label>Security Question 1</label>
<select class="form-control input-lg">
<option value="What was the name of your first pet?">What was the name of your first pet?</option>
<option value="Where did you first attend school?">Where did you first attend school?</option>
<option value="What is your mother's maiden name?">What is your mother's maiden name?</option>
<option value="What is your favorite car model?">What is your favorite car model?</option>
</select>
<br>
<label>Enter Response</label>
<input class="form-control input-lg">

</div>

<a class="btn btn-default btn-lg next" href="#">Continue</a>
</div>
<div class="tab-pane fade" id="step2">
<div class="well">

<label>Security Question 2</label>
<select class="form-control input-lg">
<option value="What was the name of your first pet?">What was the name of your first pet?</option>
<option selected="" value="Where did you first attend school?">Where did you first attend school?</option>
<option value="What is your mother's maiden name?">What is your mother's maiden name?</option>
<option value="What is your favorite car model?">What is your favorite car model?</option>
</select>
<br>
<label>Enter Response</label>
<input class="form-control input-lg">

</div>
<a class="btn btn-default next" href="#">Continue</a>
</div>
<div class="tab-pane fade" id="step3">
<div class="well"> <h2>Step 3</h2> Add another step here..</div>
<a class="btn btn-default next" href="#">Continue</a>
</div>
<div class="tab-pane fade" id="step4">
<div class="well"> <h2>Step 4</h2> Add another almost done step here..</div>
<a class="btn btn-default next" href="#">Continue</a>
</div>
<div class="tab-pane fade" id="step5">
<div class="well"> <h2>Step 5</h2> You're Done!</div>
<a class="btn btn-success first" href="#">Start over</a>
</div>
</div>

<hr>

<a href="http://www.bootply.com/wj9gWh8ulj">Edit on Bootply</a>

<hr>

</div>



<!-- Bootstrap Core JavaScript -->

<!-- js of the slider blugin-->


</body>

</html>

最佳答案

它对我有用:http://codepen.io/wvankuipers/pen/qdxVpw

我猜您面临的问题是您尝试在加载 jQuery/Bootstrap 之前使用它。要修复此问题,请将 Javascript 代码放置在该 block 中:

$(function(){ 
/* Your code here */
});

在这里阅读更多相关信息:http://api.jquery.com/jquery/#jQuery3

简短版本:这将确保在执行代码之前完全加载 DOM(并加载所需的 JS)。

关于JavaScript 问题 |进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31181585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com