Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

Trying to show certain "storyline" in HTML div tab when JS Variable is equiv to x

$
0
0

Hello folks and thank you for taking the time to look at my question.

I've asked a couple of questions recently as I am trying to make a HTML5/CSS/JavaScript based incremental game and I've run into a snag and wondering if someone could provide some help if possible.

The main game display will be a series of tab's along the top of the screen and when each tab is clicked different information will be displayed on screen relevant to each seperate section of the game's content:

i.e Tab 1 | Home // Tab 2 | Village // Tab 3 | Research etc.

Now when each of these tab's is clicked below them will be the title of the tab in a "h3" tag and then below that "h3" tab title "h3" I want to display different story content depending on the variable number located in the javascript file only problem is I'm not sure how to make the html file check the javascript file for a certain variable in order to tell the html file which part of the storyline to display when that tab is clicked.

So in summary I'm looking to find a way to display story content in each "html tab" when a javasctipt variable is equivalent to X

I think... Unless there is a simpler way to do this (The answer is probably really simple as well and it's just not clicking in my brain what I need to do...)

current code sample below:

<div id="clearing" class="tabcontent">
                    <h3>The Clearing</h3>
                    {if JS Variable === 1
                        <p>You wake up to find yourself in a strange clearing unaware of what has happened to you.
                        You scramble around with blurred vision feeling a crunch under your bare feet as you stumble around...
                        "Ugh... Where am I..., What on earth happened to me?"</p>

                        <p>You continue scrambling around and you hear faint noises in the distance...</p>
                    }

                    {if JS Variable === 2
                        <p>You make it back to the clearing after being greeted by the local population and you try 
                           to work out what your next step will be, For now though you going to need some shelter 
                           because it look's like it's going to rain quite heavily and you don't want to be caught 
                           outside in that.</p>
                    }
                </div>

Many thanks for any help you can provide.


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>