问题描述
如果我尝试使用JavaScript更改输入TEXT框中的字体,我该怎么做?b
$ b document.forms [x] .elements [y] .class = fontSize;
fontSize是一个CSS类,如果我硬编码但无法正常工作
动态地如上所述
if I am trying to change font in an input TEXT box using JavaScript how do I
do it?
document.forms[x].elements[y].class=fontSize;
fontSize being a CSS class, works if I hard code it in but will not work
dynamicly as above
推荐答案
我从中得到了一个含糊不清的信息,所以我只需要b $ b覆盖它们。
1.你只是在尝试改变元素的类?在这种情况下:
document.forms [" x"]。elements [" y"]。className =" fontSize";
2.在css中有一个font-size属性,如果那就是你想要的那么b $ b影响那么:
文件。形式[" x"]。elements [" y"] .style.fontSize =" 12pt";
There is an ambiguous messages I''m getting from this, so I''ll just
cover them all.
1. Are you just trying to change the element''s class? In that case:
document.forms["x"].elements["y"].className = "fontSize";
2. There is a font-size property in css, and if that''s all you want to
affect then:
document.forms["x"].elements["y"].style.fontSize = "12pt";
我从中得到了一个含糊不清的信息,所以我只是将它们全部覆盖。
你只是想改变元素的类吗?在这种情况下:
document.forms [" x"]。elements [" y"]。className =" fontSize" ;;
2.有一个css中的font-size属性,如果那就是你想要影响的那些:
document.forms [" x"]。elements [" y"]。 style.fontSize =" 12pt";
There is an ambiguous messages I''m getting from this, so I''ll just
cover them all.
1. Are you just trying to change the element''s class? In that case:
document.forms["x"].elements["y"].className = "fontSize";
2. There is a font-size property in css, and if that''s all you want to
affect then:
document.forms["x"].elements["y"].style.fontSize = "12pt";
我想两者兼顾,这意味着CSS类从fontSize更改为
NoStyle;我不知道你给我看的第二个选项。
谢谢
I would like to do both, meaning CSS class changing from fontSize to
NoStyle; and I did not know about the second option you showed me.
Thanks
这篇关于CSS和JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!