将Javascript放入CSS [英] Putting Javascript into CSS

查看:148
本文介绍了将Javascript放入CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想什么。在我的论坛上,有用户可以选择的默认CSS代码。这会改变从背景到文本颜色的所有内容。我有一个javascript代码。是否有可能使javascript成为CSS的一部分,因此如果某个CSS代码是默认的,那么它的一部分就是javascript?

I've been thinking about something. On my forum, there are default CSS codes that the users can choose from. This changes everything from background to text color. I have a javascript code. Is it possible to make it so that the javascript is part of the CSS, so that if a certain CSS code is defaulted, then part of it is that javascript?

推荐答案

你可以,但你真的应该不要。而是使用恰好与您使用的CSS文件对应的单独脚本文件。也许会问另一个问题,在那里你列出了一个特定的场景,你正试图解决一个特定的问题,我们可能会告诉你通常用来解决它的做法。

You can, but you really ought not to. Instead, use separate script files which happen to correspond to the CSS files you use. Maybe ask another question where you lay out a specific scenario where you're trying to solve a specific problem, and we can probably tell you the practice that's generally done to solve it.

这篇关于将Javascript放入CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆