44. Percentage Calculator And Grabbing Elements With JavaScript - Full stack web development Course
In this FullStackWebDevelopment tutorial series video, We are going to learn how to link our html file with our #javascript file. To perform any sort of #calculations on the received data we need to extract the data from the text fields. To extract those data we apply an unique #id to each text field and create a variable in the javascript file that stores an html object/element.’ Example: var numField1 = document.getElementById(‘numField1’); The document.getElementById() method returns the element of specified id. we can use document.getElementById() method to get the value of the input text. But we need to define id for the input field. Returns null if no elements with the specified ID exists. An ID should be unique within a page. However, if more than one element with the specified ID exists, the getElementById() method returns the first element in the source code. numField1.value(); OR numField1.value()=”Wbweb”; The value property sets or returns the value of the value attribute of a text field. The value property contains the default value OR the value a user types in (or a value set by a script). Syntax: textObject.value; //return the value property textObject.value = text; //set the value property var x = document.getElementById("myBtn").innerText; The innerText property sets or returns the text content of the specified node, and all its descendants. It is used to set the value of all the non-textField elements. If we set the innerText property, any child nodes are removed and replaced by a single Text node containing the specified string. Syntax: node.innerText //Return the text content of a node: node.innerText = text; //Set the text content of a node: ---------------------------- Week 1 : Day 7 Section 5 : Learning to Code With Javascript Tutorial 44: Percentage Calculator And Grabbing Elements With Javascript ---------------------------- Do subscribe and hit Bell Icon ---------------------------- Follow us in social media handles for opportunities and code related support. Instagram: https://www.instagram.com/wb.web/ Facebook: https://www.facebook.com/wbweb/ Twitter: https://twitter.com/wbweb_in/ LinkedIn: https://www.linkedin.com/company/wbweb/ ---------------------------- Got a question on the topic? Please share it in the comment section below and our experts will answer it for you. For more information, please write back to us at [email protected] or call us at IND: 7077568998 After completing the course, write to [email protected] for internship or freelancing opportunities. For consultation or partnership related queries drop a mail to [email protected].
Download
0 formatsNo download links available.