Luca Fülbier Luca Fülbier - 1 year ago 69
jQuery Question

In what order/priority does a browser get information from CSS and Javascript?

I basically had the same problem as the person in this Stackoverflow post.

The suggested solution was:


This piece of code feels really weird to me. I thought the browser builds the DOM using HTML/CSS and i can then freely manipulate it using JS/jQuery - why do i still have to change the CSS?

I am a CSS and Javascript beginner, so could someone please explain to me, why i have to manipulate the CSS before being able to use jQuery to fade in my element?

Answer Source

JQuery's css(), hide() and fadeIn() methods all change the DOM rather than the CSS you've loaded in.

In this case you change the visabilty style first using css(), then hide() changes the display style to none and then fadeIn() changes the display style to block but does so by tweening the transpaency.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download