Style Placeholder Text


The placeholder text in inputs has a light gray color. To style it, you’ll need vendor prefix CSS properties.

/* Chrome / Safari / Opera 15+ */
::-webkit-input-placeholder { color: SteelBlue; }
/* Firefox 18- */
:-moz-placeholder { color: SteelBlue; }
/* Firefox 19+ */
::-moz-placeholder { color: SteelBlue; }
/* IE 10+ */
:-ms-input-placeholder { color: SteelBlue; }

How to check if an element exists in HTML with jQuery


Recently a friend asked me how to run a function only if there is an determined element in HTML.

How can this be a common question, I decided to put on the blog.

if ( $("#element").length ) {
  // do something.

With this if() you check if an element exists on the page, and if yes (true), run a code in particular. If the if() returns false, the code inside it will be ignored.

Form test


In an internal company work, some time ago, I saw a project that had a JS that took the placeholder’s input showed with other format, with animation. If your browser supported the placeholder, he used the placeholder, if not, with js, made ​​it work.

I decided to redo, using the same idea, only without the placeholder, using only the label. Continue reading