HTML Articles

Page 10 of 151

HTML DOM KeyboardEvent metaKey Property

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 155 Views

The HTML DOM KeyboardEvent metaKey property returns a Boolean value indicating whether the meta key was pressed during a keyboard event. The meta key corresponds to the Cmd key on Mac and the Windows key on Windows systems. This property is commonly used to detect keyboard shortcuts that involve the meta key, such as Cmd+C for copy on Mac or Windows+R for the Run dialog on Windows. Syntax Following is the syntax for accessing the metaKey property − event.metaKey Return Value The metaKey property returns a Boolean value − true ...

Read More

HTML DOM KeyboardEvent shiftKey Property

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 151 Views

The HTML DOM KeyboardEvent shiftKey property is a read-only Boolean property that indicates whether the Shift key was pressed when a keyboard event occurred. It returns true if the Shift key was held down during the event, and false otherwise. This property is commonly used to detect modified key combinations, such as Shift+Enter for line breaks or Shift+Click for multi-selection functionality. Syntax Following is the syntax for accessing the shiftKey property − event.shiftKey Return Value The property returns a Boolean value − true − The Shift key was pressed during ...

Read More

Print elements that can be added to form a given sum

Sunidhi Bansal
Sunidhi Bansal
Updated on 16-Mar-2026 273 Views

This program finds and prints elements from a given array that can be added together to form a specified sum. The algorithm uses a greedy approach where it iterates through the array and selects elements that don't exceed the remaining sum value. Algorithm The greedy algorithm works as follows − START STEP 1 → Take number of elements and array values from user STEP 2 → Take the target sum from user STEP 3 → For i = 0 to n-1 STEP 4 → If (current_sum - array[i]) >= 0 then ...

Read More

HTML DOM Legend Object

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 179 Views

The HTML DOM Legend Object represents the element in the Document Object Model. The element provides a caption or title for its parent element, helping to group related form controls together with a descriptive label. Syntax Following is the syntax for creating a element using JavaScript − var legendObject = document.createElement("LEGEND"); To access an existing element − var legendObject = document.getElementById("legendId"); Properties The Legend Object has the following property − Property Description form Returns a reference ...

Read More

HTML DOM li Object

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 210 Views

The HTML DOM Li Object represents the (list item) element in the Document Object Model. This object provides properties and methods to manipulate list items dynamically using JavaScript. Accessing Li Objects You can access existing elements using various DOM methods − // Get li element by ID var liElement = document.getElementById("myListItem"); // Get all li elements var allLiElements = document.getElementsByTagName("li"); // Get li elements by class name var liByClass = document.getElementsByClassName("list-item"); Creating Li Objects Following is the syntax to create a new element − var liObject ...

Read More

HTML DOM Link href Property

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 315 Views

The HTML DOM Link href property is used to set or return the URL/path of a linked document. This property is commonly used with elements to dynamically change stylesheets, favicons, or other linked resources on a webpage. Syntax Following is the syntax for getting the href attribute value − linkObject.href Following is the syntax for setting the href attribute value − linkObject.href = string Parameters The string parameter can be the following values − Value Type Description Absolute path It ...

Read More

HTML DOM Link rel Property

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 177 Views

The HTML DOM Link rel property sets or returns the relationship between the current document and the linked document. This property corresponds to the rel attribute of the element and specifies how the linked resource relates to the current document. Syntax Following is the syntax for getting the rel attribute value − linkObject.rel Following is the syntax for setting the rel attribute to a value − linkObject.rel = valueString Parameters valueString − A string that specifies the relationship between the current document and the linked document. It can ...

Read More

HTML DOM Local Storage clear() method

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 351 Views

The HTML DOM Local Storage clear() method removes all key-value pairs from the localStorage object for the current domain. This method provides a quick way to empty the entire local storage without removing items individually. Syntax Following is the syntax for the localStorage clear() method − localStorage.clear() For sessionStorage, the syntax is − sessionStorage.clear() Parameters The clear() method does not accept any parameters. Return Value The method returns undefined and does not provide any return value. How It Works When localStorage.clear() is called, it removes ...

Read More

HTML DOM Location host Property

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 203 Views

The HTML DOM Location host property returns or sets the hostname and port number of the current URL. This property combines both the hostname (like www.example.com) and port number (like 8080) in the format hostname:port. If no port is specified in the URL, only the hostname is returned. Syntax Following is the syntax for getting the host property − location.host Following is the syntax for setting the host property − location.host = "hostname:port" Return Value The location.host property returns a string containing the hostname and port number. If the ...

Read More

HTML DOM Location href Property

AmitDiwan
AmitDiwan
Updated on 16-Mar-2026 208 Views

The HTML DOM Location href property returns or sets the complete URL of the current page. This property provides access to the entire URL including protocol, hostname, port, path, search parameters, and fragment identifier. Syntax Following is the syntax for getting the href property − location.href Following is the syntax for setting the href property − location.href = "URL" Parameters The location.href property accepts the following parameter when setting a value − URL − A string representing the complete URL to navigate to. This can be an ...

Read More
Showing 91–100 of 1,509 articles
« Prev 1 8 9 10 11 12 151 Next »
Advertisements