简体   繁体   English

如何为正在制作的应用添加类别屏幕?

[英]How do I add a category screen to an app I'm making?

I'm trying to add a category screen to an app I'm making for a class, and I'm stumped. 我试图将类别屏幕添加到我正在为一个班级制作的应用程序中,但我感到很困惑。 I don't know what to add. 我不知道要添加什么。 I've tried researching the problem, but I couldn't find anything that could help. 我曾尝试研究此问题,但找不到任何有帮助的方法。

What I've got for the code is this: 我得到的代码是这样的:

The HTML part of the code: 代码的HTML部分:

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

The JavaScript part of the code: 代码的JavaScript部分:

function displayCategory() {
  $(".screen").hide();
  $("#category-screen").show();
}

There's obviously more to the code, I'm just showing the part of the code that relates to the Category Screen. 该代码显然还有更多,我只是在显示与类别屏幕相关的代码部分。 If you need more, let me know. 如果您需要更多,请告诉我。

For the app I'm making for class, I expect the next screen to be a category screen with 4 categories after the start button is hit, but it's not. 对于我正在上课的应用程序,我希望下一个屏幕是单击开始按钮后具有4个类别的类别屏幕,但事实并非如此。 It just goes to the questions. 这只是问题。

What your javascript is doing right now is hiding the .screen class with all elements that belong to it. 您的JavaScript现在正在做什么,将.screen类及其所有元素隐藏起来。 This includes the 'categorie' divs. 这包括“类别” div。

Trying to make them visible after the hide won't have any effect since their parent node (.screen) is still hidden. 试图使它们在隐藏后可见,因为它们的父节点(.screen)仍然是隐藏的,因此没有任何效果。 As far as I can tell replacing the $(".screen").hide(); 据我所知,替换$(".screen").hide(); with $(".screen").show(); $(".screen").show(); should yield your wanted result, showing the category section. 应该会产生您想要的结果,并显示类别部分。

function displayCategory() {
  $(".screen").show();
}

function hideCategory() {
  $(".screen").hide();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM