How to add the values of HTML elements?

WBOY
Release: 2023-09-16 08:41:06
forward
1063 people have browsed it

How to add the values ​​of HTML elements?

This article will teach you how to add the value of an element in HTML. We have a basic understanding of the value attribute in HTML and the situations in which it is used. Let's look forward to a better understanding of the HTML value attribute.

In HTML, the value attribute is used to describe the value of the element with which it is used. It has different meanings for various HTML components. Usage - It can be used with,

It has different meanings for various types of input:

  • It specifies the text on the button when it appears in "button," "reset," and "submit".

  • It specifies the initial value of the input field when it appears in the "text", "password" and "hidden" values.

  • When "checkbox", "radio" and "picture" are present, it represents the value associated with the input.

HTML

Clickable buttons are defined in HTML by the

Example

In the example below, we have created two
Copy after login

HTMLTags

The

tag specifies a field for user input data. The most important form element is theelement. Theelement can be rendered in many different ways, depending on the type attribute.

Example

Consider the following example where we use an HTML form withtags with default values

   




Copy after login

When you run the above script, it will generate an output that includes an input field using the value attribute to display the first and last name default values and a submit button on the web page.

  • HTML Elements
  • List items are defined using the

  • tag. Ordered lists, unordered lists, and menu lists all use
  • tags. List items are usually displayed with bullet points in
      and . List items in
        are usually represented by numbers or letters.

        Example

        Consider the following example where we use the value attribute in an ordered list.

           
        1. THAR
        2. BMW
        3. DUCATI
        4. BENZ
        5. TERRANO
        6. CIAZ
        Copy after login

        After running the above script, the output window will pop up showing an ordered list of different cars used in the script, starting from the number 100, since we have mentioned value="100" on the web page.

        Use script

        In the example below, we are running a script to change the value of a text field.

        Example

           Name:  

        Click To Change Value

        Copy after login

        When the script executes, it will generate an output containing an input field with the value "thor" and a clicked button. When the user clicks the button, the event is fired and changes the input value on the web page = "blackwidow".

  • The above is the detailed content of How to add the values of HTML elements?. For more information, please follow other related articles on the PHP Chinese website!

    Related labels:
    source:tutorialspoint.com
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!