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
Object Oriented Programming Articles
Page 95 of 589
JavaScript - Get the text of a span element
In JavaScript, you can get the text content of a span element using several methods. The most common approaches are innerHTML, textContent, and innerText. Methods to Get Span Text There are three main properties to retrieve text from a span element: innerHTML - Gets HTML content including tags textContent - Gets plain text content (recommended) innerText - Gets visible text content Example: Getting Span Text Get Span Text ...
Read MoreJavaScript global Property
The global property in JavaScript returns true or false depending on whether the 'g' (global) modifier is set in a regular expression pattern. Syntax regexPattern.global Return Value Returns a boolean value: true - if the 'g' flag is set false - if the 'g' flag is not set Example: Checking Global Flag JavaScript Global Property JavaScript Global Property Example ...
Read MoreJavaScript Immediately Invoked Function Expressions (IIFE)
An Immediately Invoked Function Expression (IIFE) is a JavaScript function that executes immediately after it has been defined. This pattern is useful for creating isolated scope and avoiding global namespace pollution. Syntax (function() { // Code here runs immediately })(); // Alternative syntax (function() { // Code here runs immediately }()); Basic IIFE Example IIFE Example JavaScript IIFE Demo ...
Read MoreJavaScript JSON Arrays
JSON arrays are ordered lists of values enclosed in square brackets. In JavaScript, you can access and manipulate JSON arrays just like regular JavaScript arrays. Syntax { "arrayName": ["value1", "value2", "value3"] } Basic JSON Array Structure Here's how a JSON object with an array property looks: JSON Array Example let obj = { ...
Read MoreJavaScript JSON HTML
Generating HTML from JSON data is a common task in web development. You can fetch JSON data from APIs and dynamically create HTML elements to display the information. Note − JSONPlaceholder is a fake Online REST API for Testing and Prototyping. Example: Creating HTML Table from JSON JSON to HTML Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; ...
Read MoreJavaScript - know the value of GET parameters from URL
To extract GET parameters from a URL in JavaScript, you can use the built-in URL and URLSearchParams APIs. These provide a clean way to parse query strings from URLs. Using URL and URLSearchParams The URL constructor creates a URL object, and its searchParams property gives access to query parameters: GET Parameters Example body { ...
Read MoreJavaScript lastIndex Property
The lastIndex property in JavaScript is used with regular expressions to track the position where the next search will begin. It only works with the global (g) flag and automatically updates after each match. Syntax regexObject.lastIndex How lastIndex Works The lastIndex property starts at 0 and updates to the position after each match when using exec() or test() with the global flag. JavaScript lastIndex Property Finding Multiple Matches with lastIndex let text = "The king bought an expensive ring."; let regex ...
Read MoreJavaScript Let
The JavaScript let keyword, introduced in ES6 (2015), allows us to declare block-scoped variables. Unlike var, variables declared with let are only accessible within the block where they are defined. Block Scope with let Variables declared with let are confined to their block scope and cannot be accessed outside of it. JavaScript Let Example JavaScript Let Block Scope Test Block Scope ...
Read MoreJavaScript Location protocol Property
The location.protocol property in JavaScript returns the protocol scheme of the current URL, including the colon (:). This property is useful for determining whether a page is loaded over HTTP, HTTPS, or other protocols. Syntax location.protocol Return Value Returns a string representing the protocol scheme of the URL, including the trailing colon. Common values include: "https:" - Secure HTTP protocol "http:" - Standard HTTP protocol "file:" - Local file protocol "ftp:" - File Transfer Protocol Example ...
Read MoreJavaScript multiline Property
The JavaScript multiline property is a read-only property of regular expression objects that returns true if the 'm' modifier (multiline flag) has been set, and false otherwise. The 'm' flag changes the behavior of ^ and $ anchors to match at line breaks within the string. Syntax regexp.multiline Return Value Returns a boolean value: true if the 'm' flag is set false if the 'm' flag is not set Example: Checking multiline Property ...
Read More