You are here: Reference > JavaScript > client-side > style handling > methods > getPropertyPriority

getPropertyPriority method

Browser support:
9
Retrieves the priority of specified style property (the 'important' qualifier).
Note: The getPropertyValue method is supported in Internet Explorer from version 9.
The important qualifier can be set for a style property in CSS, or by the setProperty method.

Syntax:

object.getPropertyPriority ( );
You can find the related objects in the Supported by objects section below.

Return value:

String. One of the following values:
important Important qualifier is set.
empty string Important qualifier is not set.

Example HTML code 1:

This example illustrates the use of the getPropertyPriority method:
<head>
    <style>
        #myDiv {
            width:200px !important;
        }
    </style>
    <script type="text/javascript">
        function GetPriority () {
            var sheet = document.styleSheets[0];
            var rules = sheet.cssRules ? sheet.cssRules : sheet.rules;
            var rule = rules[0];

            if (rule.style.getPropertyPriority) {
                var priority = rule.style.getPropertyPriority ("width");
                alert (priority);
            }
            else {      // Internet Explorer before version 9
                alert ("Your browser does not support this example!");
            }
        }
    </script>
</head>
<body>
    <div id="myDiv">A div element</div>
    <button onclick="GetPriority ()">Get priority!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content