arithmekids's People
arithmekids's Issues
Solution for the final check of the answers
Hi,
I found a solution for the issue we faced today.
Each textfield has its own unique dom id. Each time that we generate the text field I push this dom id to an array that I created for that. In our case array is a great way to hold data.
what does it mean dom id?
When we place a text field on the board what happen is that we create a new element in the dom. This element have the unique id which we push to the array which created for holding the id's of all the text fields. Generally, when we call an element by its unique id we are very specific to a certain element. If you remember each element in the dom can have an id and/or class. Id is unique and we can't have 2 elements in the dom with the same id, like in the real world each person have unique id and we don't have 2 people with tghe same id number. Class is a bit different, some elements can have the same class, and when we do something on the class it will apply to all the elements that belong to this class. lets's say we have a div tag, this div can have a class and id, I can have another div with the same class, but the id must be different, when we go for example to our css file to design the page, if I will design the id the design will be implemented to the div with this specific id. If I will design the the class all the elements on the dom that share this class will be impacted by the design.
There are 2 ways to get the value of the text field now that we know the element id.If you remember we created a function that executed when a user click the button. In this function we can use:
- Simple JavaScript function -document.getElementById(" [id] ").value
- use a library calls jQuery. jQuery know how to target elements in the dom and it has many functions that we can excuse on specific element after we target it.
We can create a loop that iterate in the array of the unique id that we created above and for every id in the array I asked with JS function or jQuery to find the element with this id and give us the value of it.
Now, we should decide together where we want to store it for future use when we want to check if the answer is correct or not.
Next step: after we have the array of the numbers in each row and the result that the user entered, we would like to go over and check what is correct and what is not.
I would like to ask you to push the last version of the game so I will be able to work on it. and add you the functions that you need.
I will try to show up to the next class. but if not I will make sure you will understand it with one of the instructors team.
We almost there! don't give up!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.