开发者

What is "CSS on-the-fly"?

What is CSS on-the-fly? Does JavaScript allow to modify CSS 开发者_Go百科on-the-fly?


Changing an Elements CSS Attributes

The easiest way to modify CSS on the fly is probably with Jquery:

$('#elementID').css("height", "300px");

First parameter is the CSS attribute, second is the new value.

Try and steer away from over using this, as it wont degrade nicely probably for people without Javascript enabled.

Changing CSS Classes

Related info: How can I change the css class rules using jQuery?

This afaik is not possible on the fly, see above link.


You can also use .style to access css styles in javascript eg

document.getElementById("anElement").style.width = "300px";

Though I think this might only affect single elements


Yes. It does allow you to modify the CSS on the fly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜