How to Add and Remove “Required” in Jquery

Add and Remove Required in Jquery

In this blog post, we learn how to add and remove a required attribute in jquery. By this method, You not only able to remove or add the “required” attribute, But you can remove or add another attribute also. We do the task using attr() method. The attr() method sets or returns attributes and values … Read more

Auto Calculate Total Price in Javascript

Auto Calculate Total Price in Javascript

In this blog post, we learn how to auto calculate the total price on input change. This is task is very important when you are but an e-commerce project. where we need real-time calculation of product selection. To achieve this task we use getElementById() . It returns an Element object representing the element whose id property matches … Read more

Show and Hide a Div Onclick in Javascript

Show and Hide a Div Onclick in Javascript

In this blog, we learn how to Show and Hide a div on the click button in Javascript. there are several methods to do the job. In this blog post, I covered two methods first one is getElementById() and the second one is getElementsByClassName(). Method 1 : getElementById() The getElementById() returns an Element an object representing the … Read more

How to Get the Last Character of String in Javascript?

Get the Last Character of String in Javascript

In this blog post, we learn how to get the last character of string in javascript. To find the last character we have two easy methods. The first one is a slice() and another method is length properties. Method 1: Slice() The slice() the method extracts a section of a string and returns it as a new … Read more

How Pass PHP Array to Javascript

How Pass PHP Array to Javascript

The PHP array can be used in the javascript function in many ways. But today in this blog we will use the main two ways. The first one is json_encode() and the second one is most common PHP implode() function. Method 1 : json_encode() First, define an array into PHP. json_encode() returns the JSON representation … Read more

Find Longest, Shortest, and Random String in Array in Javascript


1. Find Longest String in Array Here I define an array list of six elements and we can see the Longest string is “Performance”. So run this script to get an answer. To Find the string we use reduce(). The reduce() the method executes a reducer function (that you provide) on each element of the array, resulting in a … Read more

How to Pass PHP Variable to JavaScript ?

Hello developer In this blog we will see how to access or use PHP variables in to Javascript. Sometime we need to just pass a PHP variable to Javascript on same page. So here simply set a variable value in PHP and we will use in show a alert in Javascript. HTML code In the … Read more

Image Preview Before Upload With Simple Javascript

This post describes how to preview an image before uploading it to the server by using javascript step by step. using FileReader and jquery. There are many methods to do this task. Some of them are through Jquery and some through pure JavaScript. So let’s start. Here is the result of the code Here is … Read more