Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Discover whether a div has an !important attribute

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #205774
    triplebit
    Participant

    Need to know whether or not a dom element has a rule set with important priority.
    Example:
    a div with a class of class1:
    I need to dicover the important attributes for both cases.
    .class1 {
    width: 50px !important;
    padding-left: 10px !important;
    }
    Thx
    I. Sher

    #205792
    Shikkediel
    Participant

    The only way I can think of is to access the stylesheet with JavaScript’s cssRules and let a couple of regexes loose on it…

    http://codepen.io/Shikkediel/pen/QwKMBQ?editors=001

    Not an exact example but the principle steps are included (apart from the final !important regex match itself).

    A similar thread on SO :

    http://stackoverflow.com/q/10314131/3168107

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.