首先,您不应该有具有相同 ID 的 HTML 元素。那会引起问题。其次,我建议使用 .attr()(属性)方法而不是 .prop()。
我用这些更改修改了您的代码并且它正在工作,尽管您可能想要查看您的方法并且页面上的每个按钮只有一个副本,或者,如果您想让它们为每个 div 重复,然后设置它们的属性是固定的,因为它们似乎永远不会改变。
我在下面的这些修改中包含了您的代码,但我也为您的 JSFiddle 分叉了这些更改。你可以在这里查看:http://jsfiddle.net/QTMR5/1/。
<a href="javascript:void(0)" class="show-page one" data-page="first">First</a>
<a href="javascript:void(0)" class="show-page two" data-page="second">Second</button>
<a href="javascript:void(0)" class="show-page three" data-page="third">Third</a>
<div class="container">
<div class="page first">
<div class="row">
<center>
First Page<br />
<button class="btnd btnd-default" id="firstone">Personal Info</button> <br />
<button class="btnd btnd-default" id="firsttwo">Educational Info</button> <br />
<button class="btnd btnd-default" id="firstthree">Employment Info</button>
</center>
</div>
</div>
<div class="page second hide">
<div class="row">
<center>
Second Page <br />
<button class="btnd btnd-default" id="secondone">Personal Info</button> <br />
<button class="btnd btnd-default" id="secondtwo">Educational Info</button> <br />
<button class="btnd btnd-default" id="secondthree">Employment Info</button>
</center>
</div>
</div>
<div class="page third hide">
<div class="row">
<center>
Third Page <br />
<button class="btnd btnd-default" id="thirdone">Personal Info</button> <br />
<button class="btnd btnd-default" id="thirdtwo">Educational Info</button> <br />
<button class="btnd btnd-default" id="thirdthree">Employment Info</button>
</center>
</div>
</div>
$(document).ready(function () {
$('#firstone').attr("disabled", false);
$('#firsttwo').attr('disabled', true);
$('#firstthree').attr('disabled', true);
$('.one').click(function(){
$('#firstone').attr('disabled', false);
$('#firsttwo').attr('disabled', true);
$('#firstthree').attr('disabled', true);
});
$('.two').click(function(){
$('#secondone').attr('disabled', false);
$('#secondtwo').attr('disabled', false);
$('#secondthree').attr('disabled', true);
});
$('.three').click(function(){
$('#thirdone').attr('disabled', false);
$('#thirdtwo').attr('disabled', false);
$('#thirdthree').attr('disabled', false);
});
var value = 0, progress;
function progressBar() {
progress = setInterval(function () {
var $bar = $('.bar');
if (value >= 100) {
clearInterval(progress);
$('.progress').removeClass('active');
$(".show-page[data-page=Profile]").trigger("click");
} else {
value += 10;
$bar.width(value * 7);
}
$bar.text(value + "%");
}, 800);
};
$(document).ready(function () {
if (typeof (Storage) !== "undefined" && localStorage.getItem('pageToShow')) {
var pageToShow = localStorage.getItem('pageToShow');
$('.page').addClass('hide');
$('.' + pageToShow).removeClass('hide');
};
$('.show-page').click(function () {
var pageToShow = $(this).data('page');
if (pageToShow == "progBar") {
value = 0;
$('.bar').width(0);
$('.progress').addClass('active');
progressBar();
} else {
clearInterval(progress);
};
$('.page').addClass('hide');
$('.' + pageToShow).removeClass('hide');
if (typeof (Storage) !== "undefined") {
localStorage.setItem('pageToShow', pageToShow);
};
});
});
});