偶知道 用js 动态创建的 html 元素 可以实现 ,
但不知道  直接写在 html文件 里的 元素标签 如何实现!`

解决方案 »

  1.   

    元素只能添加属性吧? 用setAttribute
      

  2.   

    写了例子,在继承方面没弄明白$D.fn.expent,怎么弄?期待高手详解<input type="text" id="aa">
    <input type="button" value="hide me" onclick="$D(this).hide()"><script>
    (function(){
        
    var $D =window.$D = function(_id){
        return new $D.fn.init(_id);
    };
    $D.fn=$D.prototype={
        element:null,
        init:function(_id)
        {
            if(typeof _id=="string")
            {
                this.element = document.getElementById(_id);
            }else if(typeof _id=="object")
            {
                this.element = _id;
            }
            return this;
        },
        hide:function(){this.element.style.display="none";},
        show:function(){this.element.style.display="block";}
        }
        $D.fn.init.prototype = $D.fn;})();$D("aa").hide();</script>
      

  3.   

    $D.fn.extend({
            check:function(){return 1;}
        });
    不知道这里用extend怎么不行
    alert($D("aa").check());
      

  4.   

    不知道楼主是不是这个意思。例如:让所有的htmlElement都有all方法直接将下面一段放入页面
    <script>
    if(window.HTMLElement){ 
        HTMLElement.prototype.__defineGetter__("all",function(){
            var a=this.getElementsByTagName("*"); 
            var node=this; 
            a.tags=function(sTagName){
                return node.getElementsByTagName(sTagName); 
               } 
            return a; 
            }); 
    }
    </script>
      

  5.   

    window.HTMLElement 为 false ....
    我IE7 
      

  6.   

    你怎么写的?? window.HTMLElement跟什么浏览器没有关系吧?是HTMLElement元素就是true,不是当然就是false了