Web from getting started to giving up <5>

Source: Internet
Author: User

<1> Css_dom

1,structural Layer

2,presentation Layer

3,behavior Layer

Style is also a property

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Title</title></Head><Body><PID= "text"style= "Background-color: #222222; color:white;">Hello World</P><Scriptsrc= "Cp_10.js"></Script></Body></HTML>


function sometest () {    var text = document.getElementById (' text ');    Console.log (typeof text, "text:", text);    Console.log (typeof Text.nodename, "NodeName:", text.nodename);    Console.log (typeof Text.style, "style:", Text.style);} Sometest ();


Get style properties:

Color= "White"

alert (Text.style.color);

Color: #cc6600;

<2> various ways to set styles:

<p style= "..." > </p>

This is not good and requires external file separation:

If you want to set all of the document's <p> element CSS:

P {    background-color: #333333;     color: White; }

If you want to set the document ID to text <p> element CSS:

P#text {    background-color: #333333;     color: White;}

If you want to set the element CSS for document ID text:

#text {    background-color: #333333;     color: White;}

If you want to set the document class as Textclass element css:

. Textclass {    background-color: #333333;     color: White;}

However, this is not a way to get the style in the DOM, but it can be set in the DOM.

function () {    var text = document.getElementById (' text ');    Text.style.backgroundColor= "#222222";     = "White";}


Web from getting started to giving up <5>

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.