Web Development Articles

Page 334 of 801

Difference between div~div and div:not(:first-of-type)?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 189 Views

In CSS, both div~div and div:not(:first-of-type) can select the same elements in many cases, but they work differently and have different specificity values. Understanding the Selectors The div~div selector uses the general sibling combinator (~) to select any div that comes after another div at the same level. The div:not(:first-of-type) selector targets all div elements except the first one of its type within its parent. Example Structure ...

Read More

How to set multiple cookies in JavaScript?

mkotla
mkotla
Updated on 15-Mar-2026 4K+ Views

In JavaScript, you can set multiple cookies by calling document.cookie multiple times. Each call adds a new cookie to the browser's cookie store. Unlike other properties, document.cookie doesn't overwrite existing cookies — it appends new ones. Basic Syntax for Multiple Cookies document.cookie = "cookie1=value1"; document.cookie = "cookie2=value2"; document.cookie = "cookie3=value3"; Example: Setting Multiple Cookies Here's a complete example showing how to add, list, and remove multiple cookies: var num = 1; ...

Read More

Polymer 1.0 dom-repeat should display index starting at 1 with HTML

Samual Sam
Samual Sam
Updated on 15-Mar-2026 211 Views

Polymer.js is a JavaScript library created by Google that allows reusing HTML elements for building applications with components. When using dom-repeat in Polymer 1.0, the index starts at 0 by default, but you can display it starting from 1. The Problem By default, dom-repeat provides a zero-based index. If you want to display numbers starting from 1 (like a numbered list), you need to add 1 to the index value. Solution: Using a Helper Function Create a helper function that adds 1 to the index: displayIndex: function(index) { return index ...

Read More

How can I show a euro or other HTML entity in JavaScript alert windows?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

This tutorial will teach us to show a euro or other HTML entities in JavaScript alert windows. JavaScript provides three types of pop-up windows: Alert box, Confirm box, and Prompt box. The alert box displays information to users, such as welcome messages or notifications. The confirm box shows confirmation messages and returns true/false based on user choice. The prompt box collects input from users through a pop-up interface. Default JavaScript alert boxes only display plain text, so we need special techniques to show currency symbols and other HTML entities. We can use Unicode escape sequences, decimal codes, or ...

Read More

How can I delete all cookies with JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 1K+ Views

To delete all cookies with JavaScript, you need to iterate through existing cookies and set their expiration date to the past. JavaScript doesn't provide a direct method to clear all cookies at once, so we must delete them individually. How Cookie Deletion Works Cookies are deleted by setting their expires attribute to a past date. When the browser sees an expired cookie, it automatically removes it from storage. Method 1: Basic Cookie Deletion This approach splits the cookie string and deletes each cookie by name: function deleteAllCookies() { var cookies ...

Read More

How to detect that JavaScript Cookies are disabled?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

This tutorial will teach you how to detect if cookies are enabled or disabled on a website using JavaScript. Cookies are small text files stored on your computer that contain data. When a web server sends a web page to a browser, it terminates the connection and forgets about the user. Cookies solve the challenge of "how to remember information about the user" by storing data like usernames for subsequent visits. Cookies allow you to store user information between page visits. Your server transmits certain data to the visitor's browser in the form of a cookie, which may be ...

Read More

How to define methods for an Object in JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 238 Views

Methods are functions that let an object perform actions or have actions performed on it. The key difference between a function and a method is that a function is a standalone unit of statements, while a method is attached to an object and can be referenced using the this keyword. Methods are used for everything from displaying object contents to performing complex mathematical operations on properties and parameters. Method 1: Defining Methods During Object Creation You can define methods directly when creating an object using object literal notation: let person = { ...

Read More

Flexbox layout losing proportions when reduced in size

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 156 Views

Flexbox items can lose their intended proportions when the container shrinks, causing layout distortion. This happens due to default flex shrinking behavior and minimum size calculations. The Problem By default, flex items have flex-shrink: 1 and min-width: auto, which can cause unexpected shrinking behavior when the container becomes smaller than the content. Item 1 with long content Item 2 Item 3 .flex-container { display: flex; width: 300px; border: 1px solid #ccc; } .flex-item { flex: 1; ...

Read More

HTML5 audio control stop button

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 1K+ Views

HTML5 audio elements don't have a built-in stop button, but you can create one by combining the pause() method with resetting the currentTime property. Basic Stop Function To stop audio playback, pause the audio and reset its current time to zero: Stop function stopAudio() { var myPlayer = document.getElementById('myAudio'); myPlayer.pause(); myPlayer.currentTime = 0; } Complete Example with Play/Stop Controls Play Stop var audio = document.getElementById('audioPlayer'); function playAudio() { ...

Read More

What is the difference between new operator and object() constructor in JavaScript?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 1K+ Views

Both the new operator and Object() constructor are used to create objects in JavaScript, but they serve different purposes and contexts. The new Operator The new operator is used to create an instance of an object. It works with constructor functions to instantiate objects and automatically handles the object creation process. var department = new Object(); var books = new Array("C++", "Perl", "Java"); var day = new Date("December 1, 2017"); document.write("Department: " + typeof department + ""); document.write("Books: " + books + ""); document.write("Date: " + day + ""); ...

Read More
Showing 3331–3340 of 8,010 articles
« Prev 1 332 333 334 335 336 801 Next »
Advertisements