When working with JavaScript, 1st let me say that when I create the document I use the file extension html in the place of js, why? Because a document js you only could run in the console, so even making very shallow Js doc I make in html, so I create a doc HTML and inside the body of the HTML doc I create a tag, everything in a HTML is isnide an tag, <script> </script>, also the CSS is another tag inside the HTML document in the part that is the head of the HTML, also you can use external Js and CSS but you gonna make an tag link for one and for the other an tag source that for the same way goona link the document for an external link(Js).
So now is to learn the best way to remember, I could make an program inside the HTML document and run using the browser, for this you don't need internet only the browser, you don't even don't need the DOM but you gonna make programs very poors that comunicates with the user by pop-ups, alert, prompt, and one that you say ok and cancel, and also we can print something in the page but of a very poor way, with all the input being receive by the prompt, very poor.
So there came the DOM to make me make interactivity in the interface, what is DOM and is Document Object Model, that I already said that is used to acess the objects of the nterface of your program that is HTML stylized by CSS, so to got acess the objects in the page (HTML document) with JS
you gonna write the variable with his name, you only generate an variable if it has a name, of course or how you gonna use it latter?
so :
var bimbom = document.querySelector('#bimbim');
See I am using the DOM to could manipulate the HTML with the JS, so I am trying find something in the Document, so my variable will have first document, and this is all before the dot and after the dot is like actions or methods that can I execute in the document, so is querySelector, that is find in the document = querySelector is you gonna seek in where in the document, that was previously declared, but querySelector is find but what? What is between in parenthesys, so this means that in the HTML I have something that can be recognized, was named if is a # is id, by bimbim. Is in parenthesys because isn't an action but part of the comand that explicite what and not how. Rute Bezerra de Menezes Gondim
No comments:
Post a Comment