I am stuck. I have used CSS to produce an input field with a background colour. I have added this to the innerHTML of the element. I would like the colour to change to green if the correct number is inputted into the field or red if the number is incorrect, once the button is clicked. My function does not sadly work. The element background will change to red (although not green) but not the background of the field.
If anyone with a bigger brain can help, I would be hugely grateful.
You can use the new HTML-Attributes feature in Hype 4, so you don´t have to create the input form inside the inner HTML field. Just look at the identity panel -> HTML attributes (contenteditable -> true)… Use ‘innerHTML’ within your script:
var inputValue = document.getElementById('inputBox').innerHTML;
if (inputValue == 5) {
document.getElementById('inputBox').style.backgroundColor = 'green';
} else {
hypeDocument.getElementById('inputBox').style.backgroundColor = 'red';
}