Skip to content

Instantly share code, notes, and snippets.

@19h47
Last active September 1, 2017 09:17
Show Gist options
  • Save 19h47/d411cac10927b029b1c081c3aa414083 to your computer and use it in GitHub Desktop.
Save 19h47/d411cac10927b029b1c081c3aa414083 to your computer and use it in GitHub Desktop.
Fun facts

1px solid black

To remind me the shorthand syntax of the border property, my technique was to think about Metal Gear Solid.

Because, 1px solid black is like Metal Gear Solid, isn't it? 😅

Find this article on dev.to

jQuery CSS method

When I started learning JavaScript, I mean jQuery, there are things I didn't understand.

One of this thing was the method $(selector).css();.

I don't use it anymore, #separationOfConcern, preferring HTML classes, but hey, changing style when user click on a button is something very cool.

One thing I didn't understand at first, and that I have noticed very recently was the stuff we pass to the method.

What is this weird syntax $(selector).css({backgroundColor: 'red', borderLeft: '1px solid black' });?
Why there are uppercases, braces, when we can pass directly the CSS like this $(selector).css('background-color', 'red');?

When you dig into the property of DOM, you notice that it was written in camel case. And of course, we can pass to the jQuery method css, either a string, an array or an object.

And this something I learned later. At first, the only thing that interested me was to turn my background color in red. And it din't matter, you learn the way you learn. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment