Found 8894 Articles for Front End Technology

How to Detect User Timezone in PHP?

AmitDiwan
Updated on 22-Nov-2022 06:26:55

4K+ Views

To detect timezone, we can either set a timezone and display or we can directly display. Here, we will see two examples − Get and Display the default timezone. Set a Timezone and Display it. Get the Default TimeZone To get the default timezone in PHP, we will use the following method − date_default_timezone_get(); Example Let us see the example − Output Default TimeZone:UTC Set a TimeZone and Display In this example, we will first set a timezone using the following method − date_default_timezone_set To get the timezone we have ... Read More

How to Detect User Timezone in JavaScript?

AmitDiwan
Updated on 13-Sep-2023 04:03:31

39K+ Views

To detect the user timezone with the name of the timzone itself, use the Internationalization API. This gives the name of the Timezone in which the user and the browser is being worked on. Detect Exact Timezone with Name Example To get the exact timezone name, we will use the Internationalization API − DOCTYPE html> Timezone document.getElementById("test").innerHTML = Intl.DateTimeFormat().resolvedOptions().timeZone; Output Get the Timezone (Difference between UTC ... Read More

How to Only Allow Numbers in a Text Box using jQuery?

AmitDiwan
Updated on 22-Nov-2022 05:45:15

11K+ Views

We can easily allow only numbers in a textbox using jQuery. Under the keyup() set the code for allowing only number values so that the textbox never accept strings. We will see two examples − Allow Only Numbers in a TextBox using jQuery replace() Allow Only Numbers in a TextBox using jQuery fromCharCode() Allow Only Numbers in a TextBox using jQuery replace() In this example, we will see how to allow only numbers in a TextBox using jQuery replace(). We must set the code under the keyup to allow only numbers while typing, else the textbox will not ... Read More

What are the basic rules for JavaScript parameters?

Shubham Vora
Updated on 15-Nov-2022 11:09:40

338 Views

In this tutorial, let us discuss the basic rules for JavaScript parameters. A JavaScript function is a code that performs a particular task. The function parameters are the name list in the function definition. Parameters are also known as formal parameters or formal arguments. We can follow the syntax below to declare parameters. Syntax function functionName(param1, param2) { } When there is no value for a parameter, a default value comes in place. Rules Declare the default parameters as the final ones to avoid an error. The JavaScript function definition does not specify a parameter type. The JavaScript ... Read More

How to use nested for loop in JavaScript?

Abhishek Kumar
Updated on 10-Nov-2022 09:02:25

11K+ Views

We use the for loop statement of JavaScript for repeating a set of statements inside the loop body a specified number of times. A nested for loop, as the name suggests, is made up of more than one for loop one nested inside of the other. This allows us to loop over multidimensional data structures such as matrices. The nested for loop in JavaScript A simple for loop executes a specified number of times depending on the initialization value and the terminating condition. A nested for loop on the other hand, resides one or more for loop inside an outer ... Read More

Can scripts be inserted with innerHTML?

Shubham Vora
Updated on 10-Nov-2022 07:40:37

7K+ Views

In this tutorial, we will learn that can scripts are inserted with innerHTML. There are various properties in JavaScript that help in working with the HTML of the current page. The innerHTML property in JavaScript is used to add the Html to the element. It also returns the content present in an element. Scripts are the programs or codes of JavaScript that makes a webpage interactive and dynamic. We can add the script in the script tag on the same page or another JavaScript page linked with an HTML file. The HTML is inserted in the innerHTML property for an ... Read More

How to fix broken images automatically in jQuery?

Shubham Vora
Updated on 21-Nov-2022 09:20:06

2K+ Views

In this tutorial, we will learn to fix broken images automatically in jQuery. Have you ever seen broken images while wondering on any website which shows only alternative text with the default icon of the broken image? Don’t you think it is a bad user experience? Obviously, it is. So, when you develop the application or website, you should write some JavaScript or jQuery code such that it can automatically replace broken images. Here, we will learn 2 to 3 different methods to fix broken images automatically using jQuery. Use the ‘onerror’ event inside the HTML ‘ ’ tag ... Read More

How to Create and Save text file in JavaScript?

Shubham Vora
Updated on 31-Oct-2023 12:50:40

92K+ Views

In this tutorial, we will learn to create and save the text file in JavaScript. Sometimes, developers need to get texts or content from the user and allow users to store content in a text file and allow the file to download to the local computer. Many JavaScript libraries are available to achieve our goal, but we have used the best two libraries in this tutorial to create and save the text file. Create a text file using custom text and save it to a local computer We will use normal JavaScript operations to create and save the text file ... Read More

What is the Arrow Function in ReactJS?

Payal Mittal
Updated on 07-Nov-2022 10:55:59

18K+ Views

React is a popular JavaScript library used to build user interface components. One of the features of React is that it allows you to use arrow functions to define React components. You may now create components using both the standard JavaScript function and the arrow function syntax, thanks to the release of ES6 arrow function syntax. Lets discuss what arrow functions are and why you should use them in your ReactJS code − About Arrow Functions The arrow function is a new feature of ES6, introduced in ReactJS 16. It allows the developer to create a function that has lexical ... Read More

What is Prettier in React?

Payal Mittal
Updated on 07-Nov-2022 10:46:54

983 Views

One of the many amazing things about React is that it’s more visually appealing than traditional web development frameworks like AngularJS. This might be because React favors a "simple" and "elastic" design over complex directives and components. Other factors contributing to React's visual appeal are the use of stateless components and declarative rendering. This means that instead of specifying how each component should look, you simply specify what data it needs and React will take care of the rest. In the end, it really depends on your personal taste − some people might prefer AngularJS' more polished look, while others ... Read More

Advertisements