Skip to content

$.css()

Arthur Guiot edited this page Oct 1, 2017 · 3 revisions

How it works?

This function was created to quickly apply a style to an element. So, you only need to give it an element, a style name property and the value of this property.

⚠️ This function will only work with the native style="" attribute of an element, which means that you can't modify the style that you defined in a .css stylesheet.

How to use it?

As I said, this function requires 3 arguments. So, as an example, let's change the background color of an element when you hover it.

HTML:

<div class="testElement">Hello World 🌎!</div>

JS:

$.on($.select(".testElement"), "mouseover", function() {
   $.css($.select(".testElement"), "background", "red")
})

You can also use with multiple styles:

$.css(".testElement", {
   "background": "red",
   "color": "blue"
});

⚠️ Questions?

Don't hesitate to ask your questions ⁉️ in the issue part 😁

Clone this wiki locally