YumJS CSS Documentation

CSS


Yum's css() syntax is different than JQuery's.

Getting CSS

Called with no parameters css() will return combined CSS of all elements passed to yum(). This is helpful when assigning to variables and copying element's CSS for later asignment. *NOTE: pass in singular elements like yum('.button').css() not collections if you only want to copy one element's CSS to another.

Setting CSS

You must pass in CSS as a string (without curly braces) and it is up to you to make sure it is valid CSS.

You have the option to append to existing CSS (default) OR to overwrite.

To overwrite existing CSS set the second parameter to true.


// append to existing CSS

yum('body').css('background: blue;');



// body will not be blue because this overwrites previous CSS

yum('body').css('color: blue;', true);// text is now blue, true overwrites previous CSS

The first argument to Yum can be a selector (as above), or reference to a collection of nodes.


// set variable buttons to the returned collection using the underscore method

const buttons = yum('.button')._;



// buttons variable can now be re-used no more DOM diving!



// set entire collection of returned buttons text to blue

yum(buttons).css('color: blue;');

If you have any questions about Yum please contact me.