le0m le0m - 1 year ago 118
CSS Question

How to reload or rerender CSS for a single HTML element?

Let's say I have a

with this CSS:

.foo {
height: 70vh;

And I change the height of
with jQuery like this:


How do I reset the CSS of
so its height is rendered

One solution that works is to reload the entire CSS file this way. But I wonder if there is a solution to only reset the CSS of
, not the entire stylesheet?

Answer Source

With jQuery, you are adding your styles to the style attribute of the element. It is removed again, if you call the function again with an empty string (""). This will remove the property in the style attribute.

If you have e.g. this command:

$('.foo').css('height', '100px');

You can revoke it by

$('.foo').css('height', '');

See also the discussion here: http://stackoverflow.com/a/4036868/3233827

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