js中设置表格和文本框的长度

<div id="customSettings" class="wizard-card" data-cardname="services">
    <h3 i18n="text:key_phy_customConfig">自定义设置</h3>                                      
    <a id="phy_addCustomConfig" role="button" class="btn"> <i class="icon-plus"></i> <span i18n="text:key_add_customConfig">添加设置</span></a><i class="icon-question-sign"></i> 
    <table style="width: 100%">
        <thead>
            <tr >
                <td style="width:30%" i18n="text:customConfig_name">名称</td>      
                <td style="width:60%" i18n="text:customConfig_value">内容</td>                   
            </tr>
        </thead>
        <tbody id="customConfig_list">
            <tr class="customConfig_input customConfig_template">
                   <td style="width:30%"><input class="customConfig_name" style="border-style: hidden;width:100%" type="text" /></td>
                   <td style="width:60%"><input class="customConfig_value" style="border-style: hidden;width:100%" type="text"/></td>    
                <td  class="removeCustomConfig_input" style="display: none;width: 10%"><a role="button" class="btn" style="width:55%"><i class="icon-remove"></i> </a></td>
            </tr>
        </tbody>
    </table>                
</div>
$("#phy_addCustomConfig")
    .click(
    function (event) {
        var customConfigArr = [];
        var tr = "<tr class='customConfig_input customConfig_template'>";       
        var td1 = "<td style='width:30%'><input class='customConfig_name' style='border-style: hidden;width:100%' type='text'  value=''></td>";
        var td2 = "<td style='width:60%'><input class='customConfig_value' style='border-style: hidden;width:100%' type='text'  value='' ></td>";              
        var td3 = "<td  class='removeCustomConfig_input' style='display: none;width: 10%'><a role='button' class='btn' style='width:55%'><i class='icon-remove'></i> </a></td>"
        customConfigArr.push(tr);
        customConfigArr.push(td1);
        customConfigArr.push(td2);
        customConfigArr.push(td3); 
        customConfigArr.push("</tr>");
        var customConfig = $(customConfigArr.join(""));
        $(customConfig).removeClass("customConfig_template");
        $(customConfig).addClass("CustomConfig_added");

        $(customConfig).find(".removeCustomConfig_input").show();
        $(customConfig).find(".customConfig_name").val("");
        $(customConfig).find(".customConfig_value").val("");
        
        $(customConfig).find(".removeCustomConfig_input").click(function () {
            $(customConfig).remove();
        });
        $("#customConfig_list").append(customConfig);     
        $(customConfig).find(".customConfig_value").blur(function(){
            $(this).parent().find(".error-popover").hide();
       });
    });

172441_u84u_2249492.jpg

转载于:https://my.oschina.net/YoYoo/blog/484788

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值