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
Javascript Articles
Page 385 of 534
How to use FastClick with jQuery Mobile the right way in HTML?
FastClick is a library that eliminates the 300ms delay on mobile browsers for touch events. However, jQuery Mobile provides a built-in solution with the vclick event that handles this automatically. The Problem with Mobile Touch Delays Mobile browsers introduce a 300ms delay between a touch event and the click event to detect double-taps. This creates a sluggish user experience on mobile web applications. jQuery Mobile's Built-in Solution jQuery Mobile includes virtual events like vclick that provide immediate response without the 300ms delay. This eliminates the need for external libraries like FastClick. Using vclick Event ...
Read MoreAdding two values at a time from an array - JavaScript
Let's say, we are required to write a JavaScript function that takes in an array of Numbers and returns a new array with elements as sum of two consecutive elements from the original array. For example, if the input array is − const arr = [3, 6, 3, 87, 3, 23, 2, 2, 6, 8]; Then the output should be − const output = [9, 90, 26, 4, 14]; Example Following is the code − const arr = [3, 6, 3, 87, 3, 23, 2, 2, 6, 8]; ...
Read MoreComparison of CSS versions
Cascading Style Sheets (CSS) has evolved significantly since its inception. Understanding the differences between CSS versions helps developers choose the right features for their projects and maintain browser compatibility. CSS1 (1996) CSS1 became a W3C recommendation in December 1996. This initial version introduced the fundamental CSS language and a basic visual formatting model for HTML elements. It provided essential styling capabilities like fonts, colors, margins, and borders. CSS2 (1998) CSS2 became a W3C recommendation in May 1998, building upon CSS1 with significant enhancements: Media-specific style sheets for printers and aural devices Downloadable fonts support ...
Read MoreType Selectors in CSS
Type selectors in CSS target HTML elements directly by their tag names. They are the most basic form of CSS selectors and apply styles to all instances of a specific HTML element throughout the document. Syntax element { property: value; } Where element is any valid HTML tag name like h1, p, div, span, etc. Example: Styling Headings h1 { ...
Read MoreCounting the clusters of positive numbers - JavaScript Arrays
Let's say, we have an array of numbers like this − const arr = [-1, -2, -1, 0, -1, -2, -1, -2, -1, 0, 1, 0]; We are required to write a JavaScript function that counts the consecutive groups of non-negative (positives and 0) numbers in the array. Like here we have consecutive non-negatives from index 3 to 3 (only one element, but still a cluster) which forms one group and then from index 9 to end of array forms the second group. Therefore, for this array, the function should return 2. How It Works ...
Read MoreDescendent Selectors in CSS
CSS descendant selectors allow you to apply styles to elements that are nested inside other elements. This targeting method helps create specific styling rules without affecting similar elements elsewhere on the page. Syntax ancestor descendant { property: value; } The descendant selector uses a space between two selectors to target elements that are children, grandchildren, or any level deep within the ancestor element. Example: Styling Emphasized Text in Lists Apply yellow color to elements only when they appear inside tags: ul ...
Read MoreCode to find the center of an array without using ES6 functions - JavaScript
We are required to write an array function midElement() that returns the middlemost element of the array without accessing its length property and without using any kind of built-in loops. If the array contains an odd number of elements, we return the one middlemost element, or if the array contains an even number of elements, we return an array of two middlemost elements. How It Works The solution uses recursion to count array elements by incrementing an index until reaching undefined, then calculates the middle position(s) based on whether the count is odd or even. Example ...
Read MoreHow to define multiple style rules for a single element in CSS?
You may need to define multiple style rules for a single element. You can define these rules to combine multiple properties and corresponding values into a single block as defined in the following example: h1 { color: #36C; font-weight: normal; letter-spacing: .4em; ...
Read MoreCounting below / par elements from an array - JavaScript
We are required to write a function that counts how many elements in an array are below or at/above a given number. Following is our array of Numbers − const array = [54, 54, 65, 73, 43, 78, 54, 54, 76, 3, 23, 78]; For example, if the number is 60, there should be 7 elements below it − 54, 54, 43, 54, 54, 3, 23 and 5 elements at or above it − 65, 73, 78, 76, 78 Using Array.reduce() Method The reduce() method processes ...
Read MoreWorking with Inline CSS
Inline CSS allows you to apply styles directly to HTML elements using the style attribute. This method applies styles to individual elements only, making it useful for quick styling or element-specific customizations. Syntax You can use the style attribute on any HTML element to define inline style rules: Style Attribute Attribute Value ...
Read More