- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 8895 Articles for Front End Technology
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
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
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
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
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
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...*/ );
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
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
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
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