Step 1
Step 2
Step 3
Step 4
.step {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.step-item {
  width: 100%;
  max-width: 100px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background-color: #eee;
  cursor: pointer;
}

.step-item.active {
  background-color: #007bff;
  color: #fff;
}
$(document).ready(function() {
  // 初始化第一个步骤为当前步骤
  $('.step-item:first-child').addClass('active');

  // 点击步骤切换当前步骤
  $('.step-item').click(function() {
    // 移除所有步骤的 active 类
    $('.step-item').removeClass('active');
    // 添加当前步骤的 active 类
    $(this).addClass('active');
  });
});

运行代码后,可以点击每个步骤来切换当前步骤的样式。

jQuery 步骤流程案例:可点击的步骤切换

原文地址: https://www.cveoy.top/t/topic/lMeT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录