In this tutorial, we will learn about the modulus operator in JavaScript. In some languages, the modulus operator is also known as the remainder operator. The remainder operator and the modulus operator both are used to get the remainder of an integer when it is divided by some other integer, but they are different from each other in case of signs of the remainder whether it has to be positive or negative that is returned after the division. In the expression a % b, a is called dividend, while b is known as divisor. In case of the modulo, the ... Read More
In this tutorial, we learn to use JavaScript DOM to change the padding of a table. To change the padding of a table, use the DOM padding property. The HTML table is used to display the relational data on the user screen. We can easily show the related or dependent data to the user and user can easily understand and determine the characteristics of the data with help of table. But, while we are showing the relational data to the user in the form of table, we need to make sure that the table is well structured and looking good ... Read More
In this tutorial, we will learn how we can change the elements of a JavaScript array in a comma-separated list. Sometimes, we need the elements of a JavaScript array in a format that is not returned by the array itself by default, so we need to write some extra code to implement this task. Fortunately, JavaScript allows us to do so by using some in-built methods. We will discuss these methods in detail. Following are the in-built methods provided by JavaScript to convert the array into a comma-separated list − Array join() method Array toString method Let us ... Read More
In JavaScript, we can check for particular class whether it is contained by an HTML element or not, in the HTML document. During the development of the web page, a developer uses many classes and sometimes assign similar classes to different elements which requires same styles in CSS. In this process, the developer may forget the class given to the particular element, then the developer may need check for the class inside the element using the JavaScript. In this tutorial, we are going to discuss how we can test if an element contains class in JavaScript. To check for the ... Read More
In this tutorial, we will learn how we can use JavaScript to replace the content of a HTML document. In JavaScript, we can change the content of HTML document with a combination of following methods − open − The open method is used to open a new document which takes two arguments as text/html and replace, where first argument will define the type of new document to be formed and the later one will replace all the adds history on the previous page and help to open new document with ease. document.open("text/html", "replace"); write − After creating ... Read More
In this tutorial, we learn to use JavaScript to load a webpage after 5 seconds. We use the setTimeout() function in JavaScript to load a webpage after some interval. This function waits for some seconds and then loads the web page. We could also apply the setInterval() method to perform our task. Generally, a web page loads immediately if the network connection to which user connected is very strong, and if the network connection is very poor, then it will take some time to load. But did you know that, we can stop the web page loading for some time ... Read More
In this tutorial, we will see how we can create a client-side image map using JavaScript. We use JavaScript to create a client-side image map. Client−side image maps are enabled by the usemap attribute for the tag and defined by special and extension tags. The image that is going to form the map is inserted into the page using the element as normal, except that it carries an extra attribute called usemap. The value of the usemap attribute is the value of the name attribute on the element, which you are about to meet, preceded ... Read More
In this tutorial, we will discuss how we can check for a number whether it is a decimal number or a whole number using the JavaScript. In JavaScript, we can use in−built methods as well as the user defined methods to check for a number if it has a decimal place or it is a whole number. We will discuss about all those methods in details. Let us see what are those methods that we can use to accomplish this task. Following methods are very useful to check for a number if it is decimal or whole number − ... Read More
In this tutorial, we will learn how we can submit an HTML form using JavaScript. To submit an HTML form using JavaScript, we are calling validate() to validate data when the onsubmit event is occurring. We will discuss the direct method of submitting the HTML form as well as the method which checks that none of the fields is empty. Both of these methods are listed below − Using the Form submit() Method Using the manual validations Let us discuss both of these methods in detail in code examples associated to each. Using the Form submit() Method The ... Read More
In this tutorial, we will learn to style the background image to no repeat with JavaScript DOM. To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page. The use of images in the background really makes the page attractive. But before using the image in the background, one must need completely understand the properties used to set the images as the background. Otherwise, it will create problems for you like not showing the full image in the background, repeating the image ... Read More