js onClick 方法 undefined

解决方法:onclick方法不能单独放置在用户的js脚本里面,可以放置在页面中用<script></script>的形式,可以解决这个问题


另外付jquery 动态增加删除表行


<script>


    function delLaserPicRow(r){
        alert("--del-"+r);
         if(confirm("确定删除?")){
             $(r).parent().parent().remove();
         }
    }

    $("#J_btn_addLaserPic").on("click", function () {
        var tr = "<tr>" +
                "<td style=\"text-align:center\"><input type=\"text\" class=\"form-control\" name=\"name\" id=\"J_name\"/></td>" +
                "<td style=\"text-align:center\"><input type=\"checkbox\" id=\"J_pic_laser\" name=\"picLaser\"/></td>" +
                "<td><div class=\"J_file-upload-control\" id=\"J_upload-control_descPic\"> <input type=\"file\" id=\"desc_fileUpload_descPic\" name=\"descFileUpload\"/></div></td>" +
                "<td style=\"text-align:center\"><input type=\"text\" id=\"J_to_head_distance\" name=\"toHeadDistance\"/></td>" +
                "<td><div class=\"J_file-upload-control\" id=\"J_upload-control_viewPic\"> <input type=\"file\" id=\"desc_fileUpload_viewPic\" name=\"viewFileUpload\"/></div></td>" +
                "<td><input type=\"button\" value='删除' οnclick='delLaserPicRow(this)'/></td>" +
                "</tr>";
        $("#selectedLaserPicList").append(tr);
    });

</script>



<table border="1" width="1000">
    <thead>
    <tr>
        <th style="text-align:center" width="25%">名称</th>
        <th style="text-align:center" width="8%">是否默认</th>
        <th style="text-align:center" width="7%">图片</th>
        <th style="text-align:center" width="10%">图片距离手机顶部位置</th>
        <th style="text-align:center" width="35%">前台展示图片</th>
        <th style="text-align:center" width="15%">操作</th>
    </tr>
    </thead>
    <tbody id="selectedLaserPicList">
        <#list laserDetail.laserRuleInfoDto.laserPicList as laserPic>
        <tr role="row" class="odd">
            <td style="text-align:center">${laserPic.name}</td>
            <td style="text-align:center"><#if laserPic.isDefault == 1>checked</#if></td>
            <td>
                <div class="J_file-upload-control" id="J_upload-control_${laserPic.desPic}">
                    <input type="file" id="desc_fileUpload_${laserPic.desPic}" name="descFileUpload"
                           />
                </div>
                <div class="prod-img-preview" id="J_image-box_${laserPic.desPic}">
                    <img data-holder-rendered="true" style="width: 100%;height:100%; display: block;"
                         src="${imgHost}${laserPic.desPic}">
                    <!--<i class="glyphicon glyphicon-remove" id="delIcon_${commoditySku.skuId}" name="delIcon"
                       skuId="${commoditySku.skuId}"></i>-->
                </div>
                <div id="J_image-size_${laserPic.desPic}" style="display: none;float:left;margin-top:5px;">
                </div>
            </td>
            <td style="text-align:center">
                <button type="button" class="btn btn-xs btn-danger J_skuSelectedDel">
                    <span class="glyphicon glyphicon-remove"></span>删除
                </button>

                <!--
                <div class="J_commoditySelectedId">
                    <input type="hidden" class="J_spuSelectedId" value="${commoditySku.spuId}"
                           name="spuId"/>
                    <input type="hidden" class="J_skuSelectedId" value="${commoditySku.skuId}"
                           name="skuId"/>
                    <input type="hidden" class="J_imgSelectedNo" id="J_img_no_${commoditySku.skuId}"
                           name="defaultImgUrl" value="${commoditySku.defaultImgUrl}"
                           skuName="${commoditySku.name}"/>
                </div>-->
            </td>
        </tr>
        </#list>
    </tbody>
</table>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值