`
hanqingzhong2
  • 浏览: 14638 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
文章分类
社区版块
存档分类
最新评论

jquery1.4新特性1-传递属性给构造器

阅读更多

传递属性给构造器:

  在1.4版本以前,jquery对象可以通过方法.css()为dom元素添加属性值。1.4版本可以通过在其后面添加一个元素对象传递给jquery对象。

 例如:

 

 

  jquery('<div/>',{

       id:'1',
       click:function(){
          alert('jquery1.4新特性');
       },
       css:{
           fontWeight:700,
           color:red
        }
      }
);
 

 

 

以前的写法:

   jquery('<div/>').attr('id','1').css({
           fontWeight:12px,
           color:red
        }
).click(function(){alert('jquery1.4新特性');});
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics