简体   繁体   English

隐藏和显示div标签

[英]hide and show div tags

I'm trying to implement a switch/tracker to my HTML5 game. 我正在尝试为HTML5游戏实现一个切换器/跟踪器。
A short description of what I want jQuery to do for me: hide all div tags and show the ones I need (body, output, language, footer and a specific level fi Level 1 Once this has been shown, it needs to show the next level fi Level 2 on clicking a bottom. 我希望jQuery为我做的简短描述:隐藏所有div标签并显示我需要的标签(正文,输出,语言,页脚和Level 1级特定级别)。一旦显示,它就需要显示下一个级别fi Level 2 ,单击底部。

But I don't know how to code this. 但是我不知道该怎么编码。 So can anyone please help me? 那有人可以帮我吗?
So far I have written this: 到目前为止,我已经写了这个:

jQuery('document').ready(function() {
    function hideshow() {
        $("div").hide(99999999);
        $("#container").show(9999999);
        $(".output").show(9999999);
        $("#languages").show(9999999);
        $("footer").show(999999);
        $("#L1").show(999999);
    };
});

It might be better practice to hide the div's with css, or even replacing the Level 1 with Level 2 content (ajax based for example). 最好用CSS隐藏div,甚至用Level 2内容替换Level 1 (例如基于ajax)。

If you cannot do that, give all level div's a class, and only hide those with 如果您无法做到这一点,请为所有级别的div分配一个类,并仅隐藏具有

$('.level').hide(); $('#level1').show();

The way to make a function show something is to do 使函数显示内容的方法是

$('#level2').show();

Use the jQuery css method: 使用jQuery css方法:


$("div").css("display", "none"); //for hiding
$("div").css("display", "block"); //for displaying

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

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