I'm having a bit of trouble of getting the JavaScript code right. I need some help on what goes where and how it's supposed to look.
This is what I have so far in my script.
<script>
var i = "1";
var listItem = "";
function processInput() {
if (i <= 5) //Comparison operator//
document.getElementById("listItem").innerHTML = (i <= 5);
</script>
Here is my question:
Create a function called processInput(). Within the function create an if statement that runs if the value of i is less than or equal to 5. The if statement should perform the following actions:
- Set the value of the listItem variable to the string "item" concatenated with the value of i.
- Set the content of the element with an id equal to listItem to the value of the element with the id or toolbox.
- Set the value of the element with the id of toolbox to an empty string.
I'm not sure if I'm setting this up right. I have tried w3Schools and the information on their site seemed to be unhelpful/unclear.
Aucun commentaire:
Enregistrer un commentaire