week 4 (code journal) Flashcards
in js forms, what is the name attribute in tags for?
e.g. name=”title”
how do you use the “required” attribute for forms?
just type required. no value is needed.
e.g.
<textarea>
</textarea>
what does this do:
$newObj.title = document.forms[0].elements.title.value;
And what does the [0] here do instead of “title”?
$newObj.title = document.forms[0].elements[0].value;
the value of the element with the name “title” among elements within the first form (index 0) on the document is is being set as the title variable within the $newObj.
they both do the same thing except the second is searching by index instead of the “name” attribute
what does this do:
$newObj.title = document.forms[0].elements.title.value;
And what does the [0] here do instead of “title”?
$newObj.title = document.forms[0].elements[0].value;
the value of the element with the name “title” among elements within the first form (index 0) on the document is is being set as the title variable within the $newObj.
they both do the same thing except the second is searching by index instead of the “name” attribute
what does this do?
localStorage.getItem(‘javascript-local-storage’);
it goes into local storage in the browser and gets the value stored in local storage, and in this case the keyName is ‘javascript-local-storage’