Found 6710 Articles for Javascript

How to create previous and next button and non-working on end position using JavaScript?

Shubham Vora
Updated on 28-Feb-2023 16:39:53

7K+ Views

There are many ways to create previous and next button and non-working on-end positions using JavaScript. We will cover two approaches to achieve this functionality - one using normal if conditions and the other using the "disabled" attribute. The second approach utilizes the "disabled" attribute to make the button not clickable and updates the button style for nonworking end positions. By implementing these techniques, we can easily navigate through a set of elements, making the user experience more seamless and intuitive. Let’s see both methods with examples for creating this kind of button in JavaScript. Using only if conditions ... Read More

How to create own Ajax functionality?

Shubham Vora
Updated on 28-Feb-2023 16:38:20

357 Views

An Ajax (Asynchronous JavaScript and XML) request is an HTTP request made using JavaScript, typically with the XMLHttpRequest object, to exchange data with a server and update a specific part of a web page without requiring full page refresh. There are two ways to create own Ajax functionality. You can use JSONPlaceholder API or your own file. We will discuss these two ways in detail in this tutorial. Using JSONPlaceholder API JSONPlaceholder is a free online REST API that you can use to test and practice your development skills Syntax Users can follow the below syntax for creating an ... Read More

How to show Page Loading div until the page has finished loading?

Shubham Vora
Updated on 28-Feb-2023 16:36:29

12K+ Views

Rather than showing the whole white or black screen while loading the page, it is better to show the loading indicator, which also improves the UX of the application. Nowadays, there are some libraries available to show loading indicators. However, we can use HTML and CSS to create a customized loading indicator div. In this tutorial, we will use HTML, CSS, and JavaScript to show page loading div until the page has finished loading Use the onreadystatechange event to show the loading indicator while loading the page In JavaScript, the onreadystatechange event triggers whenever the state of the web ... Read More

How to serialize a cookie name-value pair into a Set Cookie header string in JavaScript?

Shubham Vora
Updated on 28-Feb-2023 16:34:55

979 Views

The cookie allows us to store users’ data in the web browser for quick response. For example, when a user opens the profile page in any web application, the web page receives the data from the server. The server also sends the cookies containing the data to store in the web browser. When a user goes on the profile page again, it fetches the data from the cookie rather than fetching it from the server to load the webpage quickly. To get data browser looks in the cookie first, and if it doesn’t find data stored in the cookie, it ... Read More

How to check an element with specific id exist using JavaScript?

Aman Gupta
Updated on 27-Feb-2023 16:04:18

4K+ Views

Overview To check for a specific id in a HTML element to attain a certain task can be achieved with help of JavaScript. So to achieve the solution to the problem, we should have knowledge about how to access the HTML Document Object Model (DOM). So the HTML element that is specified with an id name can be accessed by the document object, which contains several methods from which we will be using the getElementById() method. Syntax The basic syntax used is − document.getElementById() document −In the given syntax, the document is the object that is loaded when ... Read More

How to check a URL contains a hash or not using JavaScript?

Aman Gupta
Updated on 27-Feb-2023 15:53:16

854 Views

Overview To check whether a Uniform Resource Locator (U.R.L.) contains a hash (#text) or not with JavaScript, as JavaScript contains some pre-build methods which makes a straightforward task to obtain a certain goal. This can be done by using the hash property in JavaScript, which can be accessed by initializing the window.location object. It eases the user-interface and provides a foremost navigation through the web page. To build this solution, we need prior knowledge on the following topics − HTML- To build the skeleton of the page. In which we will use an internal tag. HTML Events (onclick(), ... Read More

Why do we have External CSS and JS files

Devesh Chauhan
Updated on 27-Feb-2023 14:38:26

510 Views

In this article we will learn about the CSS and JS files. We will explore about their functions and different ways of using them in HTML document. And after learning about all these things we will understand why we have external CSS and JS files.CSS CSS stands for Cascading Style Sheets. CSS is used to apply styles to your websites and webpages. It is used to make webpages look more understandable, presentable and more appealing to the user. A CSS file can be written in any text editor but must be saved with a .css extension. A simple HTML ... Read More

How to simulate target="_blank" in JavaScript ?

Gungi Mahesh
Updated on 24-Feb-2023 13:33:10

7K+ Views

The onclick event occurs only when a user clicks the elements and it is a purely JavaScript attribute. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because it may create the confuse to the users. So, use these event very wisely. The window.open() method is used to open the links or web pages in a new window or tab in the browser. It is supported by all the famous browsers like chrome, firefox, and opera. window.open() ... Read More

How to simulate a click with JavaScript ?

Gungi Mahesh
Updated on 24-Feb-2023 13:30:57

2K+ Views

The getElementById() produces an object of element which represents the element whose id attribute matches the provided string. Because element IDs must be unique if supplied, they're a convenient method to rapidly retrieve a single element. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because it may create the confuse to the users. So, use these event very wisely. The ‘textContent’ property of the element, is used to set or return the content of the text. ... Read More

How to set textarea scroll bar to bottom as a default using JavaScript/jQuery?

Gungi Mahesh
Updated on 24-Feb-2023 13:25:28

3K+ Views

The scrollTop property of HTML DOM elements is used to set or return the number of pixels of an elements content which is scrolled vertically. Suppose if the scroll bar is not generated by the content elements then the value of the scrollTop is zero. The onclick event occurs only when a user clicks the elements and it is a purely JavaScript attribute. Whenever you click on the onclick event it does some actions like displaying a message or redirects the user another page. The onclick event must be used very less in the website, because it may create the ... Read More

Advertisements