![]() The program entry point is when the DOM has finished loading. We now have the essential technical details and workflow to put it all together. When you call shift, it removes whatever is on the top element of the array and returns its value-it allows us to store the return value to a variable, that was why it was assigned to currcard. The shift method of the JS Array provides the mechanism to take the top card from the deck. We will need the data stored on the current card when we check the user’s answer against the answer key (which is stored on the current card). It was defined outside the Draw function so that it other functions will have access to it. The variable currcard is initially defined as null. We can do this by embedding two script elements in the head region of the html code. We will use JQuery for DOM manipulation, surely by now you must be tired of typing document.getElementById. The JavaScript part of our solution will be in an external file named script.js, so our JS and HTML codes don’t mingle up. We will use the old school input element for the text field and we will use the button element for, well, the button. We will handle the image using the img tag. We won’t use any fancy divs or nested tables so that we won’t get distracted by styling clutter. Will make the html portion quite spartan. Make sure the simplest scenario is working.If the guess is incorrect, display a “Try again message”, clear the text field and await for the response. If the user guesses correctly, proceed to the next picture and let the user guess again. The user will guess who or what the picture is by typing his answer on the provided text field and clicking the submit button. When the page loads up, a picture will be shown.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |