Chinaunix首页 | 论坛 | 博客
  • 博客访问: 925514
  • 博文数量: 264
  • 博客积分: 10107
  • 博客等级: 上将
  • 技术积分: 2455
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-09 16:34
文章分类

全部博文(264)

文章存档

2012年(1)

2011年(11)

2010年(128)

2009年(82)

2008年(42)

我的朋友

分类: 系统运维

2010-05-31 18:17:43

Jquery动态创建DOM元素

 

jquery动态创建页面元素,mark一下,以备以后查询时使用。
以创建div和input为例。
动态创建div:

01 $(function(){
02     $("
",{
03      id: 'test',
04      text: 'this is a test',
05      "class": "test",
06      click: function(){
07         $(this).toggleClass('test');
08      }
09      }).appendTo("body");
10 })

动态创建input:

01 [/javascript]
02 $(function(){
03      $("", {
04         type: 'text',
05         val: 'test',
06         focusin: function() {
07             $(this).addClass('active');
08         },
09         focusout: function() {
10         $(this).removeClass('active');
11         }
12       }).appendTo("body");
13 })
14 [javascript]
您可以任意转载本文,但转载时请以超链接形式标明文章原始出处和作者信息及版权声明
作者:muxi,原文链接:%e5%8a%a8%e6%80%81%e5%88%9b%e5%bb%badom%e5%85%83%e7%b4%a0.html
阅读(1146) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~