基于Jquery的动态创建DOM元素的代码

时间:2010-12-28    点击:105   
动态创建div:
复制代码 代码如下:

$(function(){
$("<div>",{
id: 'test',
text: 'this is a test',
"class": "test",
click: function(){
$(this).toggleClass('test');
}
}).appendTo("body");
})

动态创建input:
复制代码 代码如下:

$(function(){
$("<input>", {
type: 'text',
val: 'test',
focusin: function() {
$(this).addClass('active');
},
focusout: function() {
$(this).removeClass('active');
}
}).appendTo("body");
})
使用JavaScript检测Firefox浏览器是否启用了Firebug的代码
JavaScript动态调整TextArea高度的代码
JavaScript性能陷阱小结(附实例说明)
javascript写的日历类(基于pj)
Jquery下attr和removeAttr的使用方法
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved