zoukankan      html  css  js  c++  java
  • 模仿jq里的选择器和color样式

     1 (function(){
     2             HTMLElement.prototype.css = function () {
     3             var option;
     4             if (arguments.length > 0) {
     5                 option = arguments[0];
     6                 if (2 === arguments.length) {
     7                     option = {}, option[arguments[0]] = arguments[1];
     8                 }
     9 
    10                 if ('object' === typeof option) {
    11                     for (var key in option) {
    12                         if (option.hasOwnProperty(key)) {
    13                             this.style[key] = option[key];
    14                         }
    15                     }
    16                 }
    17 
    18             }
    19             console.dir(this)
    20             return this;
    21         };
    22 
    23             function $id(id){
    24                 return document.getElementById(id);
    25             }
    26             function $clas(cla){
    27                 return document.getElementsByClassName(cla)[0];
    28             }
    29 
    30             window["$id"]=$id;
    31             window["$clas"]=$clas;
    32 
    33         })()
    34 
    35         $id('get').onclick=function function_name () {
    37                if (true) {
    38                 $clas('dom').css('background','red');
    39                };
    40 
    41         }
  • 相关阅读:
    4.2.1 B
    4.1.1 A
    C
    A
    排序(sort qsort)
    晕,
    clipssubviews = clipstobounds
    scrollview once more,滑出来的 刚好等于 上下偏移的,
    关于 层的显示,
    水倒过来,倒过去,穷折腾啊,
  • 原文地址:https://www.cnblogs.com/webSong/p/6346551.html
Copyright © 2011-2022 走看看