Style attributes in JS

Source: Internet
Author: User

Now I need to assign a value to this tag, whose content is:
1. The text to be displayed is "hello world ";
2. span's background-color: red, and also: border: 1px solid #333333; cursor: hand;

I need to assign values to them in <script> </script>. How can I write them? Do you want:
Document. getElementById ("a"). style. background = "red"; to write one item?
Can I write the style all at once? How can I write it?
Solution:
1. Define a CSS rule first, and then this. className =''
2. document. getElementById ("a" ).style.css Text = "border-collapse: collapse; border-spacing: 1; border: 1 solid #0B2565; background-color: white; color: black ;"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.