You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

课程项目App分类页面添加故障:点击开始按钮未跳转至分类页

问题分析与解决方案

Hey there! Let's break down the issues you're facing with your category page and fix them step by step, plus I'll share some ideas to beef up the page content.

1. HTML 重复 ID 问题(规范+功能隐患)

First off, your category page HTML has a critical issue: multiple <h4> tags using the same id="category". IDs in HTML must be unique—duplicates will mess up JS targeting and violate web standards. Let's fix that by using a class instead:

<div class='screen' id='category-screen'> 
  <h4 class='category-item'>Comics</h4> 
  <h4 class='category-item'>Movies</h4> 
  <h4 class='category-item'>Games</h4> 
  <h4 class='category-item'>Misc.</h4> 
</div>

2. JavaScript 选择器错误(导致页面切换失效)

Your displayCategory function has an invalid selector: $("screen") won't target anything. If you're trying to hide other screen containers, you need to use the right selector syntax. Here's the corrected version:

function displayCategory() { 
  // Hide all screen elements except the category screen
  $(".screen").not("#category-screen").hide(); 
  $("#category-screen").show(); 
}

The original $("screen") was missing the class/id prefix—.screen targets elements with the screen class, and .not() ensures we don't hide the category page itself.

3. Core Issue: Start Button Event Binding

The main problem (clicking start jumps straight to questions) is almost certainly due to:

  • Your start button is bound to both displayCategory() and the question page jump function
  • Or it's an <a> tag that triggers a default redirect without being stopped

Fix this by:

  1. Making sure the start button only calls displayCategory() first
  2. Adding click events to your new .category-item elements to trigger the question page jump after the user selects a category:
// Bind start button to show category page
$("#start-button").click(function(e) {
  e.preventDefault(); // Stop default link behavior if it's an <a> tag
  displayCategory();
});

// Bind category items to jump to question page
$(".category-item").click(function() {
  const selectedCategory = $(this).text();
  // Add your logic to load questions for the selected category here
  // e.g., show the question screen and pass the category value
});

Ideas to Enhance Your Category Page

Since you mentioned not knowing what to add, here are some user-friendly touches:

  • Add icons to each category (e.g., a comic book icon for Comics, film reel for Movies) to make the page more visual
  • Add hover/active states to category items (change background color, add a border) to give users feedback
  • Add short descriptions under each category (e.g., "Classic & modern comic book trivia" under Comics)
  • If you plan to expand categories later, add a search bar to filter items
  • Add a "Random Category" button for users who want a surprise

内容的提问来源于stack exchange,提问作者50Shades

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:13:59