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 499 of 534
Adding default search text to search box in HTML with JavaScript?
A default search text is a text that provides suggestions or a hint of what to search for in the search (input) box. Following is an illustration of a search box, where you can observe a default search text "Search your favorite tutorials…": Search your favorite tutorials... The above default search text will suggest to visitors that they can search for their favorite tutorial, which they want to read or open on the website. HTML placeholder Attribute In HTML, the text that appears inside a ...
Read MoreAdd elements to a Queue using Javascript
In JavaScript, there is no built-in queue data structure like other programming languages. However, you can implement a queue using an array object and perform operations like push() to add elements at the end and shift() to remove the first element. The following diagram illustrates the queue data structure and its FIFO (First In, First Out) principle: 10 20 30 40 ...
Read MoreHow to set text font family in HTML?
To change the text font family in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML tag, with the CSS property font-family. HTML5 does not support the tag, so CSS styles are used to control font appearance. Keep in mind that the usage of the style attribute overrides any style set globally. It will override any style set in the HTML tag or external style sheet. Syntax Content here Example: Basic Font ...
Read MoreHow can I trigger a JavaScript click event?
In JavaScript, you can programmatically trigger a click event on an element using the click() method. This is useful for automating user interactions or creating custom behaviors. Using the click() Method The click()
Read MoreCan we make print button without JavaScript?
In this tutorial, we will learn to make a print button without writing separate JavaScript files. Most websites have print functionality that opens the browser's print dialog when clicked. While HTML doesn't have a built-in print method, we can use the window.print() method directly in HTML attributes. This allows us to create print functionality without external JavaScript files. Syntax The basic syntax for invoking the print method: window.print(); // Opens browser's print dialog Using the onClick Event We can call window.print() directly in HTML using the onClick event attribute. Syntax ...
Read MoreHow to find out which JavaScript events fired?
In this tutorial, we will learn how we can find out which JavaScript event is fired or triggered. We can add events to HTML elements to perform some actions on the webpage like changing text, form submission, etc. There are two ways of finding which JavaScript event is fired − Using Developer Tools Using Inspect Element Let us discuss both of them one by one with coding examples. Using Developer Tools We can find out which JavaScript event is fired by using developer tools in the browser. ...
Read MoreWhat is the difference between local storage vs cookies?
Local storage and cookies are two different ways to store data in web browsers, each with distinct characteristics and use cases. Understanding their differences helps you choose the right storage mechanism for your web application. Storage Capacity Local storage offers significantly more storage space than cookies: Local Storage: Typically 5-10 MB per domain Cookies: Limited to 4 KB per cookie, with a maximum of about 20 cookies per domain Server Communication The key difference lies in how they interact with servers: // Local Storage - stays on client side localStorage.setItem('username', 'john_doe'); ...
Read MoreHow to secure my JavaScript using "Strict mode"?
In this tutorial, we are going to learn how to secure my JavaScript using "Strict mode". There are some errors in the code which are just ignored by the JavaScript engine and if any line fails it performs nothing. To indicate that there is an error we can use strict mode which will make the JavaScript engine throw an error. The 'use strict' is a literal expression which is a directive we can add to the code. We can add this 'use strict' directive to the whole script, a function, or a class. Syntax Now let's see ...
Read MoreHow much data can I store in JavaScript cookies?
JavaScript cookies have size and quantity limits that vary by browser. Understanding these constraints is essential for effective web storage planning. Cookie Storage Limits by Browser Each browser imposes different limits on cookie storage. Here are the current limitations: Web Browser Maximum Cookies per Domain Maximum Size per Cookie Google Chrome 180 ...
Read MoreHow to set src to the img tag in HTML from another domain?
To use an image on a webpage, use the tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load. With HTML, you can add the image source as another domain URL by setting the src attribute to point to an external domain. Syntax Key Attributes Attribute Description src The URL of the image (can be ...
Read More