jquery動(dòng)態(tài)添加文本框

字號(hào):


    jquery動(dòng)態(tài)判斷文本框,并對(duì)數(shù)組的字?jǐn)?shù)進(jìn)行判斷,主要是有一個(gè)jquery的live事件,添加代碼如下
    $(.noadd).click(function(){//進(jìn)行添加
     if($(#tp >ul >li).size()>10){alert(最多只能添加10個(gè)投票條目!);return;} 
     $(#tp >ul).append(<li><input type='text' maxlength='51' class='biaodan' id='jiaoyan' title='50個(gè)字符以?xún)?nèi)' changdu='50' ><input type='button' alt='刪除' class='node' ><span>最多50個(gè)字符</span></li>);
     $(.node).live('click',function(){
      $(this).parent().remove();
        });
     $(#tp >ul >li >input[type='text']).live('keyup',function(){
       $(this).parent().find(span).html(最多+$(this).attr(changdu)+字,已輸入+$(this).val().length+字,剩余+(number($(this).attr(changdu))-$(this).val().length)+字);
        });
     });
    操作對(duì)象如下
    <div id=tp>
    <ul>
    <li>
    <input type=button alt=添加 class=noadd title=最多只能添加10個(gè)投票條目/>
    </li><!--內(nèi)容名稱(chēng)改變時(shí)同時(shí)要改變jq代碼的名稱(chēng)-->
    </ul>
    </div>