/mejsx

Javascript Extensions for Common Operations

Primary LanguageJavaScriptMIT LicenseMIT

MeJsX Javascript Extension Functions

MeJsX is beeing developed for common javascript operations

Functions:

1. getCustomCssRulesOnElement(element)

This function is useful when you need to access CSS style rules applied by the author.

  • Excludes HTML elements' default CSS properties
  • Includes rules from external stylesheets
  • Includes rules from internal styles
  • Includes rules from style attribute
  • Returns the rules as this order:
    1. External stylesheets, load order into the document
    2. Internal styles, written order in the document
    3. Style attributes on the element

Usage

var element = document.getElementById('idOfElement');
var elementRules = MEJSX.getCustomCssRulesOnElement(element);

// elementRules is an array of elementRule

// elementRule has 3 properties:

// elementRule.order => Ordering number of the rule
// elementRule.content => CSS content
// elementRule.media => Media query

elementRule

Example project on jsFiddle: https://jsfiddle.net/er_han/39g2c838/