Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Web Development Articles
Page 13 of 801
HTML DOM Input Text defaultValue Property
The HTML DOM Input Text defaultValue property is used for setting or getting the default value of a text field. The defaultValue of an element is the initial value assigned to the value attribute in HTML. The key difference between the value property and defaultValue property is that defaultValue retains the original default value specified in HTML, while the value property changes based on user input in the field. Syntax Following is the syntax to get the defaultValue property − var defaultVal = textObject.defaultValue; Following is the syntax to set the defaultValue property − ...
Read MoreHTML DOM Input Text name Property
The HTML DOM Input Text name property is used for setting or returning the name attribute of an input text field. The name attribute helps in identifying form data after it has been submitted to the server and is essential for form processing. Syntax Following is the syntax for setting the name property − textObject.name = "name" Following is the syntax for getting the name property − var name = textObject.name Here, textObject is a reference to the input text element, and name is a string specifying the name attribute ...
Read MoreHTML DOM Input Text placeholder property
The HTML DOM Input Text placeholder property is used for setting or returning the placeholder attribute value of an input text field. The placeholder property provides a hint to users about the expected input by displaying greyed-out text inside the input field before any user input. Unlike the value property, placeholder text is not submitted with the form data. Syntax Following is the syntax for setting the placeholder property − textObject.placeholder = "text" Following is the syntax for getting the placeholder property − var placeholderText = textObject.placeholder Here, text represents ...
Read MoreHTML DOM Input Text required property
The HTML DOM Input Text required property is associated with the required attribute of an element. This property allows you to set or check whether a text field must be filled before form submission. When a required field is left empty, the browser prevents form submission and displays a validation message. Syntax Following is the syntax for setting the required property − textObject.required = true|false Following is the syntax for getting the required property − var isRequired = textObject.required; Property Values The required property accepts boolean values − ...
Read MoreHTML DOM small object
The HTML DOM small object represents the HTML element in the Document Object Model. The element is used to display text in a smaller font size, typically for disclaimers, copyright notices, or fine print. Through the DOM, we can dynamically create, access, and manipulate small elements using JavaScript. Syntax Following is the syntax for creating a small object − var smallElement = document.createElement("SMALL"); Following is the syntax for accessing an existing small element − var smallElement = document.getElementById("smallId"); Creating a Small Element The createElement("SMALL") method creates a ...
Read MoreHTML DOM source object
The HTML DOM source object represents the HTML element in the Document Object Model. The element is used to specify multiple media resources for media elements like , , and . We can create and access source elements using DOM methods like createElement() and getElementById() respectively. The source object allows developers to dynamically add media sources to enhance browser compatibility by providing alternative formats for different devices and browsers. Syntax Following is the syntax for creating a source object − var sourceElement = document.createElement("SOURCE"); Following is the syntax for accessing an ...
Read MoreHTML DOM Span object
The HTML DOM Span object represents the HTML element in the Document Object Model. The element is an inline container used to group text or other inline elements for styling or scripting purposes. We can create new span elements dynamically using JavaScript or access existing ones to manipulate their content and properties. Syntax Following is the syntax for creating a span object − var spanElement = document.createElement("SPAN"); Following is the syntax for accessing an existing span object by ID − var spanElement = document.getElementById("spanId"); Following is the syntax ...
Read MoreHTML DOM Storage Event
The HTML DOM storage event is triggered when changes occur in the browser's storage areas (localStorage or sessionStorage). This event fires when another window, tab, or frame modifies the storage, making it useful for synchronizing data across multiple windows of the same origin. The storage event is particularly valuable for creating real-time communication between different browser windows or tabs without requiring server-side communication. It only triggers when the storage change originates from a different browsing context, not from the current window itself. Syntax Following is the syntax for adding a storage event listener − window.addEventListener("storage", ...
Read MoreHTML DOM Storage getItem() method
The HTML DOM Storage getItem() method is used to retrieve the value of a specific item from web storage by providing its key name. If the key exists, it returns the stored value as a string. If the key doesn't exist, it returns null. The getItem() method works with both localStorage (persistent storage) and sessionStorage (temporary storage that expires when the tab closes). Syntax Following is the syntax for the Storage getItem() method − localStorage.getItem(keyname); OR sessionStorage.getItem(keyname); Parameters The getItem() method accepts a single parameter − ...
Read MoreHTML DOM Storage length property
The HTML DOM Storage length property returns the number of key-value pairs stored in the browser's storage object. This property works with both localStorage and sessionStorage objects, providing a simple way to count stored items. Syntax Following is the syntax for the Storage length property − localStorage.length sessionStorage.length Return Value The length property returns an integer representing the number of items currently stored in the storage object. If no items are stored, it returns 0. Example − localStorage Length Following example demonstrates how to get the number of ...
Read More