JS control CSS style method _javascript skills

Source: Internet
Author: User
The effect of the brothers ' questioning in the group
<ptml> <pead> <title> Untitled document </title> <style>p.p1{Background-color: #FF0000; font-size : 22px;_ font-family: "Founder Shu Body"; font-weight:100; }</style> <script language= "JavaScript" > Function remove () {var WC = document.stylesheets[0], I; for (i = 0; i < wc.rules.length i + +) wc.removerule (i); } </script></pead> <body><p Class=p2 founder Shu Body "; font-weight:100; " > Hello,this is a example of stylesheets</p> <form> <input type= "button" value= "Press me to cancel the downlink background setting" onclick= "R Emove () "> <p class=p1> hello,this is a example of stylesheets</p> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Good control CSS on the Internet
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "> <title>js control style </title> <style type=" TEXT/CSS ">/* this don't go. * * {font-size:12px; } </style> <script type= "Text/javascript" > (function () {if window. Cssstylesheet) {var WC = window. Cssstylesheet.prototype; Wc.addrule = function (A, b) {var WC = this; Wc.insertrule (A + "{" + B + "}", Wc.cssRules.length); }; Wc.removerule = function (a) {var WC = this; Wc.deleterule (a); }; WC.__DEFINEGETTER__ ("Rules", New Function ("Return this.cssrules"); } })(); var addrule = function (A, b) {var WC = document.stylesheets[0], I; for (i = 0; i < wc.rules.length; i + +) if (Wc.rules[i].selectortext = = a) wc.removerule (i); Wc.addrule (A, b); }; var add = function () {var WC = document.getElementById ("WC"). Value; if (/([^\{]+) \s* (\{[^}]+\})/.test (WC)) {addrule (regexp.$1, regexp.$2); else {alert ("style error"); } }; </script> <span class= "Font" > I am the word </span><pr/> <button onclick= "Add ()" > Control </button > <textarea id= "WC" > Font {font-size:18px; Font-weight:bold; line-height:20px; Color: #FF0000; } </textarea> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.