Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
glenn romaniuk
33,659 Pointshow force css refresh
i have a page that is constructed of main and html partials. I have some jquery that toggles classes on a div. It gets added but nothing happens as the dom is not refreshing the css. How can I force a refresh with css3, jquery, or javascript?
2 Answers
glenn romaniuk
33,659 Pointsi don't have a working example its a small part of a large solutions that is very complex i've had this happen before where the served page is assembled using html partials with angular and other frameworks basically if programatically add a class to an element the dom doesn't always reload is there a way to fake, trick or invoke and update to the dom to trigger the refresh of the css?
Dave McFarland
Treehouse TeacherBrowsers will apply the CSS, IF the class is actually applied to the element. Can you inspect the element that's not showing the style you expect and make sure that the class is actually on that element?
I just talked to Jim Hoskins and he says there are lots of problems combining Angular with jQuery -- I'm not that familiar with Angular so can't comment on it -- but he says its possible that Angular might be changing back the class after jQuery applies it. Again, I'd inspect the elements to see how the HTML is actually being rendered.
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherDo you have an example of your code? Maybe I'm not understanding your set up, but browsers don't need to have the CSS refreshed. Updates to the DOM automatically trigger the application of CSS>