Found 6710 Articles for Javascript

How to make text italic in HTML?

Lakshmi Srinivas
Updated on 09-Jan-2020 08:31:12

17K+ Views

To make text italic in HTML, use the … tag or … tag. Both the tags have the same functioning, but tag is a phrase tag, which renders as emphasized text.Just keep in mind that you can get the same result in HTML with CSS font-style property.ExampleYou can try to run the following code to make text italic in HTML using … tagLive Demo           HTML italic text               Products                Our products: Online HTML Editor and Online Image Editor. ... Read More

How to 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

How do I create and read a value from the cookie in JavaScript?

usharani
Updated on 16-Jun-2020 11:50:52

183 Views

Create cookiesThe simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this −document.cookie = "key1=value1;key2=value2;expires=date";Here 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 not be accessible.ExampleTry the following. It sets a customer name in an input cookie.Live Demo                                                 ... Read More

How to make text bold in HTML?

Monica Mona
Updated on 06-Sep-2023 14:16:19

41K+ Views

To make text bold in HTML, use the … tag or … tag. Both the tags have the same functioning, but tag adds semantic strong importance to the text. The tag is a physical markup element, but do not add semantic importance.Just keep in mind that you can get the same result in HTML with CSS font-weight property.ExampleYou can try to run the following code to make text bold in HTML using … tagLive Demo           HTML text bold               Our Products       Developed ... Read More

How to set src to the img tag in html from the system drive?

Manikanth Mani
Updated on 09-Jan-2020 08:42:43

19K+ Views

To use an image on a webpage, use the tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load.With HTML, add the image source as the path of your system drive. For that, add the src attribute as a link to the path of system drive where the image is stored. For example, file:/D:/images/logo.pngThe following are the attributes:Sr.No.Attribute & Description1AltThe alternate text for the image2HeightThe height of the image3IsmapThe ... Read More

How do I print Unicode characters in the console using JavaScript?

Shubham Vora
Updated on 22-Jul-2022 12:55:58

4K+ Views

In this article, we will learn how to print Unicode characters in the console using JavaScript. No matter the platform, the software, or the language, Unicode assigns a unique number to each character.Most writing systems' characters are defined by the universal character set known as Unicode, which also assigns each character a unique number (code point). A unit of data called an abstract character (or character) is used to organize, manage, or represent textual data.Most of the modern languages' letters, punctuation marks, diacritical markings, mathematical symbols, technical symbols, arrows, emoji, and other symbols are all included in Unicode.These are different ... Read More

How do I print a message to the error console using JavaScript?

Ali
Ali
Updated on 16-Jun-2020 13:52:32

301 Views

To print a message to the error console, use the console object. Here’s an example −The following will show a red error message −console.error(message);The following gives you the default message −console.log(message);The following gives you the warning message −console.warn(message);The following gives an information message −console.info(message);Add CSS to the log message −console.log('%c Add message!, "background: green; color: white;");Use the following to print error. Consider “num” as the variable name −console.error('num=%d', num);For complete API reference, refer Console API Reference.

How to access cookies using document object in JavaScript?

Saurabh Jaiswal
Updated on 06-Jan-2023 12:58:06

8K+ Views

With JavaScript, you can easily access/ read cookies with the “document.cookie” property. Reading a cookie is just as simple as writing one because of the value of the document.cookie object is the cookie. The document.cookie string will keep a list of name=value pairs separated by semicolons, where the name is the name of a cookie and value is its string value. In this article, we will learn how to access cookies using document object in JavaScript. Syntax document.cookie Return value − All the cookies are saved in the browser in a single string. The document.cookie string will keep ... Read More

How do I print debug messages in the Google Chrome JavaScript Console?

Ali
Ali
Updated on 16-Jun-2020 13:35:05

328 Views

To print debug messages in the Google Chrome JavaScript Console, write a script, which is not creating console functions if they do not exist −if (!window.console) console = {}; console.log = console.log || function(){}; console.warn = console.warn || function(){}; console.error = console.error || function(){};Above you can see the following functions are used to log items based on a log, warn or info. It won’t cause errors when the console isn’t available. The following functions work in Google Chrome console −console.log( ); console.warn(); console.error();The Console object is used to access the browser's debugging console. As an example, consider the Web Console ... Read More

How to set cookies to expire in 30 minutes in JavaScript?

Prabhas
Updated on 09-Jan-2020 08:07:48

7K+ Views

You can extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.ExampleYou can try to run the following example to set cookies to expire in 30 minutesLive Demo                                                  Enter name:                    

Advertisements