JS中style属性
更新时间:2006年10月11日 00:00:00 作者:
现在我需要对这个标签赋值,其内容为:
1、需要显示的字为“HELLO WORLD”;
2、span的 background-color : red ,另外还要:border:1px solid #333333;cursor:hand;
我需要在<script></script>内把他们赋值,请问怎么写呢?难道要:
document.getElementById("a").style.background="red"; 来一项一项的写?
能不能一下子把style写完啊,怎么写啊?
解决办法:
1、先定义一个CSS规则,然后this.className=''
2、document.getElementById("a").style.cssText="border-collapse:collapse;border-spacing:1;border:1 solid #0B2565;background-color:white;color:black;"
1、需要显示的字为“HELLO WORLD”;
2、span的 background-color : red ,另外还要:border:1px solid #333333;cursor:hand;
我需要在<script></script>内把他们赋值,请问怎么写呢?难道要:
document.getElementById("a").style.background="red"; 来一项一项的写?
能不能一下子把style写完啊,怎么写啊?
解决办法:
1、先定义一个CSS规则,然后this.className=''
2、document.getElementById("a").style.cssText="border-collapse:collapse;border-spacing:1;border:1 solid #0B2565;background-color:white;color:black;"
相关文章
Javascript表达式中连续的 && 和 || 之赋值区别
了区分赋值表达式中出现的连续的 ‘&&’和 ‘||’的不同的赋值含义,做了一个小测试.2010-10-10
JavaScript数组方法之findIndex()的用法详解
findIndex()方法是一个非常实用的数组方法,可以帮助我们快速查找符合某个条件的元素,本文给大家介绍JavaScript数组方法之findIndex()的用法,感谢的朋友跟随小编一起看看吧2023-10-10


最新评论