JSFiddle - React, Tailwind, and code Playground

by lindsayrattray

HTML

<!--The heading text is below.  It is class h1 (heading 1) and I have given it its own id of 'title'-->

<h1 id="title">
    Native Apps vs. Web Apps: The Great Debate Pt. 3 of
</h1>

<!--below is the button-->
<button onclick="killLindsay()">Kill Lindsay</button>

CSS

/* the information below will affect all the elements of the HTML that are h1 (heading 1) */
h1 {
    font-family: Helvetica, Arial, sans-serif; /* remove Helvetica */
    font-size: 3.0em; /* try another size */
    font-style: normal; /* try italic */
    color: blue; /* try another colour */
    text-shadow: -2px 2px 3px green; /* change the numbers or colour */
}

JavaScript

// this is our basic title, assigned to 'baseText':
var baseText = "Native Apps vs. Web Apps: The Great Debate Pt. 3 of ";

// this is how many parts we've got so far, assigned to 'howManyParts':
var howManyParts = 3

// this runs when you press the button
function killLindsay()
{
    // this gets the element with id 'heading' (look up at the HTML) and sets it to baseText + howManyParts
    document.getElementById("title").innerHTML = baseText+howManyParts;
    
    // this increases the number of parts for the next time you press the button:
    howManyParts += 1;  
}