Found 8895 Articles for Front End Technology

How to center the JavaScript alert message box?

Shubham Vora
Updated on 02-Aug-2022 13:46:53

9K+ Views

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 of 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 More

How to customize the position of an alert box using JavaScript?

mkotla
Updated on 16-Jun-2020 12:45:56

2K+ Views

To customize the position of an alert box, use the CSS “top” and “left” properties. We have a custom alert box, which we’ve created using jQuery and styled with CSS.ExampleYou can try to run the following code to customize the position of an alert box −Live Demo                          function functionAlert(msg, myYes) {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes").unbind().click(function() {                confirmBox.hide();   ... Read More

How I can show JavaScript alert box in the middle of the screen?

Giri Raju
Updated on 25-Sep-2019 08:53:43

1K+ Views

To show the JavaScript alert box in the middle, you need to use the custom alert box. Under that, style it accordingly and position it to the center. Use the “top” and “left” CSS properties to achieve this. Set them as 50%, but as you can see a button below, use the property to 40% to align it with the button:ExampleLive Demo                          function functionAlert(msg, myYes) {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);     ... Read More

How I can set the width and height of a JavaScript alert box?

Nishtha Thakur
Updated on 16-Jun-2020 13:38:12

3K+ Views

To set the width and height of an alert box in JavaScript, you need to use the custom alert box. This alert box is styled with CSS.Set the width and height of the alert box using the following code, which uses jQuery, a JavaScript library −Example                                function functionAlert(msg, myYes)          {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes").unbind().click(function()       ... Read More

How do I check if an array includes an object in JavaScript?

Shubham Vora
Updated on 20-Jul-2022 08:01:11

5K+ Views

In this tutorial, we will learn to check whether an array includes an object or not. The actual array contains the values with the same data types. In JavaScript, the array is replaced with the list, including values with any data type even if users can add the objects inside the list with numbers and strings.So, programmers sometimes need to figure out if the array contains the objects or not. Programmers can access the object properties and perform some operations if the array contains an object.Here, we have different methods to check whether the array contains an object.Using the array.includes() ... Read More

How to test if a JavaScript cookie has expired?

mkotla
Updated on 17-Jun-2020 06:43:19

3K+ Views

To test if a cookie has expired in JavaScript, add the following condition and check −if( !($.cookie('myCookie') === null) ) {    // Do something (cookie exists) } else {    // Do something (cookie expired) }You can also check it using a single line code −checkCookie = $.cookie('myCookie') === null ? ( /*Condition TRUE...*/ ) : ( /*Condition FALSE...*/ );

How can I change the styling of JavaScript alert button?

Ranjit Kumar
Updated on 16-Jun-2020 13:30:26

434 Views

To change the styling of JavaScript alert button, use the custom alert box. You can try to run the following code to change the styling of alert buttons. The button looks different and more fancy −ExampleLive Demo                                function functionAlert(msg, myYes)  {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes").unbind().click(function() {                confirmBox.hide();             }); ... Read More

How to change the color of the alert box in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 11:29:03

8K+ Views

In this tutorial, we will learn to change the color of the alert box in JavaScript. Also, we will learn to style the whole alert box, including the content of the alert box. In JavaScript, the alert box is the best way to show the success, failure, or informative messages to the user, when the user performs some operation on the application. The programmers can create the default alert box using the alert() method, but they can’t change the default style of the alert() box. To change the style of the alert box, programmers need to create the custom alert ... Read More

How to preserve leading 0 with JavaScript numbers?

Shubham Vora
Updated on 20-Oct-2022 08:23:14

3K+ Views

In this tutorial, we will learn how to preserve leading 0 with JavaScript numbers. Sometimes we need to sort strings that are similar to numbers. For example, 10 comes before 2, but after 02 in the alphabet. Leading zeros are used to align numbers in ascending order with alphabetical order. Following are the methods used to preserve leading zero with JavaScript numbers. Using the Number as a String The number is converted into a string using string manipulation, and the leading zero is preserved. Syntax myFunc2('Neel', 27, '0165') The function myFunc2() is called, and the values are passed ... Read More

How to split JavaScript Number into individual digits?

Abhishek
Updated on 25-Nov-2022 08:22:16

4K+ Views

In this tutorial, we will learn how we can split a JavaScript number into individual digits. Sometimes, we need to split the number into individual digits to accomplish the task given to us like checking for the palindrome number. Let us discuss the methods to split numbers into digits. When the number is taken in the form of a number. When the number is taken in the form of a string. Let us discuss both of them individually with program examples. When the input is in form of a number If the input number is in the form ... Read More

Advertisements