JS中style属性_Javascript教程-查字典教程网
JS中style属性
JS中style属性
发布时间:2016-12-30 来源:查字典编辑
摘要:现在我需要对这个标签赋值,其内容为:1、需要显示的字为“HELLOWORLD”;2、span的background-color:red,另外...

现在我需要对这个标签赋值,其内容为:

1、需要显示的字为“HELLOWORLD”;

2、span的background-color:red,另外还要:border:1pxsolid#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:1solid#0B2565;background-color:white;color:black;"

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类