Found 2202 Articles for HTML

How can I add debugging code to my JavaScript?

Krantik Chavan
Updated on 17-Jan-2020 11:06:09

208 Views

To add debugging code to JavaScript, use the alert() or document.write() methods in your program. For example,var debugging = true; var whichImage = "widget"; if( debugging ) alert( "Calls swapImage() with argument: " + whichImage ); var swapStatus = swapImage( whichImage ); if( debugging ) alert( "Exits swapImage() with swapStatus=" + swapStatus );Examine the content and order of the alert() as they appear, you can examine the health of your program very easily.

How to reduce the number of errors in scripts?

Ramu Prasad
Updated on 23-Jun-2020 07:03:36

234 Views

To reduce the number of errors in scripts, follow the below-given tips −Use plenty of comments. Comments enable you to explain why you wrote the script the way you did and to explain particularly difficult sections of code.Always use indentation to make your code easy to read. Indenting statements also make it easier for you to match up the beginning and ending tags, curly braces, and other HTML and script elements.Write modular code. Whenever possible, group your statements into functions. Functions let you group related statements, and test and reuse portions of code with minimal effort.Be consistent in the way you ... Read More

What is a Document Object Model?

Priya Pallavi
Updated on 18-May-2020 08:47:22

757 Views

A Document object represents the HTML document that is displayed in that window. The Document object has various properties that refer to other objects, which allow access to and modification of document content.The way a document content is accessed and modified is called the Document Object Model, or DOM. The Objects are organized in a hierarchy. This hierarchical structure applies to the organization of objects in a Web document.Window object − Top of the hierarchy. It is the utmost element of the object hierarchy.Document object − Each HTML document that gets loaded into a window becomes a document object. The document ... Read More

How to use GoJS HTML5 Canvas Library for drawing diagrams and graphs?

Nancy Den
Updated on 25-Feb-2020 07:01:47

504 Views

GoJS is a JavaScript library, which you can use to implement interactive diagrams. This page will show you the essentials of using GoJS. If you want to add diagrams and graphs, then use this library, which is Open Source.GoJS has a model-view architecture, in which Models holds arrays of JavaScript objects, which describe nodes and links. To visualize this data using actual Node and Link objects, the Diagrams act as views.Constructing a Diagram with GoJS creates an HTML5 Canvas element to be placed inside the given DIV element.How to draw a diagramStart working with GoJS, you need to declare the ... Read More

How to store data in the browser with the HTML5 localStorage API?

Daniol Thomas
Updated on 25-Feb-2020 07:02:41

255 Views

HTML5 localStorage saves string data in the browser and lasts beyond the current session. localStorage stores the data, with no expiration, whereas sessionStorage is limited to the session only. When the browser is closed, the session is lost.The Local Storage is designed for storage that spans multiple windows and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user's mailbox, on the client side for performance reasons.You can try to run the following code to learn how to work with HTML5 localStorageExampleLive Demo   ... Read More

What are free libraries for Canvas in HTML5?

Yaswanth Varma
Updated on 02-Sep-2022 11:10:33

1K+ Views

Using scripting, the canvas element is utilised to create graphics instantly (usually JavaScript). This tag is just introduced in HTML5. The element serves only as a holding area for images. To draw the visuals, you must utilise a script. There are numerous ways to draw pathways, boxes, circles, characters, and add images on a canvas. Syntax Here is the simple HTML example to depict the usage of canvas − DOCTYPE html> var c=document.getElementById("myCanvas"); var ... Read More

How to use year input type in HTML?

Yaswanth Varma
Updated on 05-Sep-2022 13:44:45

24K+ Views

Use the placeholder attribute to let the user know that the required input format is YYYY, and the , min, and max attributes to limit the range of possibilities. To the first argument of a new Date, pass the value or valueAsNumber during the input event () Following are the examples… Example In the following example we are using placeholder to mention that the input type is year. DOCTYPE html> document.querySelector("input[type=number]") .oninput = e => console.log(new Date(e.target.valueAsNumber, 0, ... Read More

How to use different step attribute in one range input in HTML?

Yaswanth Varma
Updated on 02-Sep-2022 11:08:02

1K+ Views

The permitted number intervals are determined by the HTML input type step property. Steps are numerical steps such as 0, 2, 4, 6, 8, and so on. To construct a range of valid values, combine the step attribute with the max and min properties. They establish a stepping interval on a range which is executed by moving the slider left to right or spinner up and down. If its not explicitly mentioned, default steps are assigned to various input values. Syntax Default step values for different input values are as follows − Input Type ... Read More

What is the correct way of using
,
, or
in HTML?

Yaswanth Varma
Updated on 02-Sep-2022 11:05:24

8K+ Views

There are multiple correct ways to use a br tag in the web documents. In HTML, a line break is made with the tag. We don't need to close because it's an empty tag. To break a line, either or are acceptable. However, tags are used in other web documents like XHTML. But the tag must possess a space before the trailing /> as it helps XHTML to render the existing HTML user agents. Syntax Text text Following are the examples…. Example: (using ) In the following example we are using ... Read More

How to limit maximum items on multiple input ()?

Jennifer Nicholas
Updated on 25-Feb-2020 07:22:28

13K+ Views

To allow multiple file uploads in HTML forms, use the multiple attributes. The multiple attributes work with email and file input types.For limiting maximum items on multiple inputs, use JavaScript. Through this, limit the number of files to be uploaded. For example, let’s say only 2 files to be uploaded at once.You can try to run the following code to learn how to use multiple attributes in HTML. With that, we will limit the number of files uploaded using JavaScript.ExampleLive Demo           HTML file upload                   ... Read More

Advertisements