Set JavaScript Cookie with No Expiration Date

Prabhdeep Singh
Updated on 07-Nov-2022 08:25:24

2K+ Views

In this tutorial, we are going to learn to set a JavaScript cookie with no expiration date. Web servers deliver cookies, which are tiny files with frequently unique identifiers, to browsers. Each time your browser requests a new page, the server will receive these cookies. It allows a website to keep track of your preferences and online behavior. The expiration option in a JavaScript cookie is optional. The “expires” attribute is optional. If you provide this attribute with a valid date or time, then the cookie will expire on a given date or time, and thereafter, the cookies' value will ... Read More

Serialize a JavaScript Array

Prabhdeep Singh
Updated on 07-Nov-2022 08:20:39

3K+ Views

In this tutorial, we are going to learn to serialize JavaScript arrays. The serializeArray() method serializes all forms and forms elements like the .serialize() method but returns a JSON data structure for you to work with. A JavaScript array of objects may be created using the built-in jQuery function serializeArray() that is ready to be encoded as a JSON string. It utilizes a set of forms and/or form controls from jQuery. There are several sorts of controls. Any JavaScript object may be converted into JSON using a JSON string, which can then be sent to the server. Syntax Now let’s ... Read More

Select Multiple Options in a Dropdown List with JavaScript

Prabhdeep Singh
Updated on 07-Nov-2022 08:14:24

11K+ Views

In this tutorial, we are going to learn how to select multiple options in a dropdown list with JavaScript. Basically, we are going to make two buttons, one is a drop-down button in which we provide more than one option, and another is a normal button connected to the multiFunc() function with an id of the dropdown button, when we click this button then we are able to select multiple options in the drop-down button. In this tutorial we are using two properties of JavaScript one is DOM property i.e. document.getElementById and another one is multiple properties use to choose ... Read More

Secure JavaScript Using Strict Mode

Prabhdeep Singh
Updated on 07-Nov-2022 08:07:42

226 Views

In this tutorial, we are going to learn how to secure my JavaScript using “Strict mode”. There are some errors in the code which are just ignored by the JavaScript engine and if any line fails it perform nothing, to indicate that there is an error we can use the strict mode which will make the JavaScript engine throw an error. The ‘use strict’ is a literal expression which is the directive we can add to the code, not in any block. We can add this ‘use strict’ directive in the whole script, a function, or in a class. Syntax ... Read More

Return HTTP or HTTPS Protocol of Web Page with JavaScript

Prabhdeep Singh
Updated on 07-Nov-2022 08:02:14

1K+ Views

In this tutorial, we will look at how to find which protocol is being used by a web page. A web page mostly uses http or https protocol. A protocol is a type of standard which is used to specify, how the data is transferred or transmitted between different sets of computer. HTTP − HTTP is a protocol for retrieving resources such as HTML pages. It is one of the most essential and the backbone for all types of data exchange that happens over the internet. HTTP is a client server protocol which means that all the requests are done ... Read More

Round Up a Number in JavaScript

Prabhdeep Singh
Updated on 07-Nov-2022 07:57:31

1K+ Views

In this tutorial, we will discuss how to round up a number in JavaScript. There is a property in JavaScript under ‘Math’ named “ceil” with the help of this property we can easily round up a number in JavaScript. Ceil() is a mathematical function that computes an integer x to greater than or equal to x. If x has the decimal value zero or is a simple integer then it returns x, and if the number is a decimal number (x.yz, here yz is a non-zero number) then it returns x+1. Syntax var x = A.B var value = Math.ceil(x); ... Read More

Return Visible Part of Positioned Element in JavaScript

Prabhdeep Singh
Updated on 07-Nov-2022 07:51:59

211 Views

This tutorial teaches us how to return which part of a positioned element is visible in JavaScript. Positioned element is an element in JavaScript or Html which have some defined position it could be absolute which means fixed, or any relative position. To make the defined part visible only we are going to clip, remove, or hide the not required area by using the ‘clip’ property of the ‘style’ property of any element. We are going to define an area as a rectangle and defined its portion how much we are required to trim and how much we need to ... Read More

Return Background Color of an Element with JavaScript DOM

Prabhdeep Singh
Updated on 07-Nov-2022 07:40:37

4K+ Views

In this tutorial, we will explore the method by which we can get the background color of an element with JavaScript. There are many scenarios where we may want to get the color of an element on the page, and we will see how to achieve that easily using inbuilt methods provided by JavaScript. We cannot only retrieve the color of the color we can also set the color of an element using the same function. To achieve this, we will be using a modification of the same function. Browser Support Chrome Browser − Version 1.0 and above. Edge ... Read More

Return Position of Element Relative to Floating Objects in JavaScript

Prabhdeep Singh
Updated on 07-Nov-2022 07:32:28

469 Views

This tutorial teaches us how to return the position of the element relative to floating objects in JavaScript. To set the relative position or to get or return the relative position we are going to use the ‘clear’ property of JavaScript which is defined under the style property of an object. There are a total of four relative positions that are ‘left’, ‘right’, ‘top’, and ‘bottom’, and if we relatively position an object then it will fill all the gaps of that particular side. The float property of the JavaScript language can be used to set the property of the ... Read More

Return the Color of Text with JavaScript

Prabhdeep Singh
Updated on 07-Nov-2022 07:20:35

4K+ Views

In this tutorial, we will learn how to return the color of the text with JavaScript. In the Style (It is a rule of HTML, used to describe how a document will be presented in the browser.) we define the color under that rule of HTML. To return the color of the text in JavaScript, we have to use the color property of JavaScript. The Colour property is used for assigning the color of the text inside the HTML tags (like p, h1, h2, body, etc.), and with the help of the id of the tag we can return the ... Read More

Advertisements