jquery动态创建div与input的实例代码
无意中发现的,做为收藏,以备后绪查看时用。
实例如下:
<html> <head> <title>jjquery动态创建div与input</title> <script type="text/javascript" src="jquery-1.4.2.min.js"></script> <script> <!--动态创建div--> $(function (){ $("<div>",{ id:'text', text:'this is a test', "class":"text", click:function(){ $(this).toggleClass('test'); } }).appendTo("body"); }) <!--动态创建input--> $(function(){ $("<input>",{ type:'text', val:'text', function:function(){ $(this).addClass('active'); }, focusout:function(){ $(this).removeClass('active'); } }).appendTo("div"); }) </script> </head> <body></body> </html>
相关推荐
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%&qu
牵手白首 2020-05-14
开心就好 2020-06-10
huha 2020-10-16
TLROJE 2020-10-26
echoes 2020-08-20
nercon 2020-08-01
zhanghaibing00 2020-06-28
Aveiox 2020-06-25
henryzhihua 2020-06-21
zhoutaifeng 2020-06-17
liangzhouqu 2020-06-16
TONIYH 2020-06-11
x青年欢乐多 2020-06-06
KyrieHe 2020-06-03
bertzhang 2020-06-02
haokele 2020-05-29
niehanmin 2020-05-28