You are here: Reference > JavaScript > client-side > style handling > properties > accelerator

accelerator style property

Browser support:
Specifies or returns whether the object contains an accelerator key.
The underlined accelerator keys are only visible when the ALT key is pressed.

Syntax:

object.accelerator;
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: accelerator

Possible values:

The type of this property is string.
 One of the following values: 
false
The object does not contain an accelerator key.
true
The object contains an accelerator key.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the accelerator property:
<head>
    <style>
        .example {
            accelerator: true;
        }
    </style>
</head>
<body>
    <label for="user"><u class="example">U</u>ser Name: </label>
    <input type="text" id="user" accesskey="U" value="User name here" />
    <br /><br />Press the ALT + U to use the accelerator!
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the accelerator property in JavaScript:
<head>
    <script type="text/javascript">
        function ChangeAcceleratorState (button) {
            var uObj = document.getElementById ("myU");

            if ('accelerator' in uObj.style) {
                var accState = uObj.style.accelerator;
                uObj.style.accelerator = (accState == "true")? "false" : "true";
                button.innerHTML = "Change accelerator to " + ((accState == "true")? "true" : "false");
            } else {
                alert ("Your browser doesn't support this example!");
            }
        }
    </script>
</head>
<body>
    <label for="name"><u id="myU" style="accelerator:true;">N</u>ame: </label>
    <input id="name" type="text" accesskey="N" value="Enter your name!" />
    <br /><br />
    Press the ALT key and view the (N) at the beginning of the "Name" label!<br />
    If you press ALT + N, the cursor will jump into the labels input field.

    <button onclick="ChangeAcceleratorState (this);">Change the accelerator state!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content