解决方法: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>