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 288 of 534
How to center the JavaScript alert message box?
In this tutorial, we will learn to center the JavaScript alert box. In JavaScript, an alert box is useful to show users some message, information, warning, success, etc. Let's understand it by real-world example when you open any website on the web browser and start to authenticate by entering your username and password. When you click the submit button, it gives a message in an alert box like the password should be 8 or more characters, or sign in successfully. Users can create the alert box using JavaScript's alert() method. Unfortunately, the default alert box doesn't allow us to ...
Read MoreWhat is the difference between void, eval, and the Function constructor in JavaScript?
JavaScript provides three distinct features for executing and manipulating code: void, eval(), and the Function constructor. Each serves different purposes and has unique characteristics. The void Operator The void operator evaluates an expression and always returns undefined. It's commonly used to prevent unwanted return values or create undefined values explicitly. Syntax void expression void(expression) Example // Basic void usage console.log(void 0); ...
Read MoreWorking with element for CSS
You can put your CSS rules into an HTML document using the element. This tag is placed inside ... tags. Rules defined using this syntax will be applied to all the elements available in the document. Syntax /* CSS rules go here */ selector { property: value; } Example Following is an example of embedded CSS ...
Read MoreWhy does the JavaScript void statement evaluate an expression?
The JavaScript void operator evaluates an expression and always returns undefined, regardless of what the expression returns. This is useful for preventing unwanted side effects in web pages. What is the void Operator? The void operator takes any expression, evaluates it, and returns undefined. It's commonly used in links to prevent navigation while still executing JavaScript code. Syntax void expression void(expression) Example: Using void(0) in Links The most common use case is void(0) in hyperlinks to prevent page navigation: Understanding JavaScript void(0) ...
Read MoreHow to use style attribute to define style rules?
The style attribute allows you to apply CSS rules directly to individual HTML elements. This is called inline CSS and provides element-specific styling with the highest specificity. Syntax Content Example: Basic Inline Styling Inline CSS Example This is inline CSS Styled div with multiple properties Example: Multiple Style Properties ...
Read MoreHow can I stop a video with JavaScript in Youtube?
In this tutorial, we will learn to stop a video with JavaScript on YouTube. Using the 'iframe' HTML element, we can easily embed the YouTube videos on our application. It is a video player in HTML 5 and has many attributes that users can use according to their needs. In some cases, it happens that you want to create a custom pause or stop button for the embedded YouTube video. Customized buttons are always pretty rather than default ones, making UI pretty. So, we will learn two different methods to create the custom stop button for the YouTube ...
Read MoreHow to create and apply CSS to JavaScript Alert box?
The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS. Why Custom Alert Boxes? JavaScript's built-in alert() function creates browser-native dialogs that cannot be styled. Custom alert boxes give you complete control over appearance, animations, and user experience. Example You can try to run the following code to learn how to create and apply CSS to alert box: ...
Read MoreHow to check if a variable is an integer in JavaScript?
In this tutorial, we will learn to check if a variable is an integer in JavaScript. Before we solve the problem, we must have a problem. We can ask ourselves, "why do we need to check if the variable is an integer?". Let's understand the answer using a single example. Suppose, we are taking the value from the user using the input text box. It returns the values in the string format, and now think that we are adding values. Will we get the correct result? Obviously, not. So, in such cases, we need to check if the variable is ...
Read MoreHow to create JavaScript alert with 3 buttons (Yes, No and Cancel)?
The standard JavaScript alert box won't work if you want to customize it. For that, we have a custom alert box, which we're creating using jQuery and styled with CSS. Understanding the Problem JavaScript's built-in alert() and confirm() functions are limited - they only provide basic "OK" or "OK/Cancel" options. To create a custom dialog with Yes, No, and Cancel buttons, we need to build our own solution using HTML, CSS, and JavaScript. Complete Example Here's a complete implementation of a custom alert with three buttons: ...
Read MoreIncluding an external stylesheet file in your HTML document
The element can be used to include an external style sheet file in your HTML document. An external style sheet is a separate text file with .css extension. You define all the Style rules within this text file and then you can include this file in any HTML document using element. Creating an External CSS File Consider a simple style sheet file with a name new.css having the following rules: h1, h2, h3 { color: #36C; font-weight: normal; letter-spacing: .4em; ...
Read More