You are here: Reference > JavaScript > client-side > HTML DOM > properties > value (attribute)

value property (attribute)

Browser support:
Sets or returns the value of the current attribute.
The value property is similar to the nodeValue property, but it always returns the value of an attribute as a string in Internet Explorer as well. Note: the nodeValue and value properties of an attribute object always return null for certain event attributes (e.g. onload) in Internet Explorer, regardless of whether they are specified.
To get the name of an attribute, use the name property.

Syntax:

object.value;
You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

String that sets or retrieves the value.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the value property:
<head>
    <script type="text/javascript">
        function GetOnClickValue (elem) {
            var  attr = elem.attributes["onclick"];
            alert (attr.value);
        }
    </script>
</head>
<body>
    <button onclick="GetOnClickValue (this);">Get the value of the onclick attribute!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content