<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="jquery-3.0.0.min.js"></script> </head> <body> <div class="main"> <div class="tag-mess-phone"> <label for="createDateRange" class="control-label label-tag tag-mes-control-label">电话号码</label> <input class="form-control" id=‘inputphoneValue2‘ onkeyup="value=value.replace(/[^\d]/g,‘‘)" placeholder="请输入手机号" maxlength="11"> <button class="btn margin-left" onclick="deletePhone(this)" type="button">删除</button> </div> <div class="tag-mess-send-add"> <button onclick="addMessPhone()">添加</button> </div> </div> <script> function addMessPhone(){ var $params=‘‘; $params+=‘<div class="tag-mess-phone">‘ $params+=‘<label for="createDateRange" class="control-label label-tag tag-mes-control-label">‘+"电话号码"+‘</label>‘ $params+=‘<input class="form-control" id="inputphoneValue2" placeholder="请输入手机号" onkeyup="value=value.replace(/[^\d]/g,\‘\‘)" maxlength="11">‘ $params+=‘<button class="btn margin-left" onclick="deletePhone(this)" type="button">‘+"删除"+‘</button>‘ $params+=‘</div>‘ $(".tag-mess-send-add").before($params); } function deletePhone(e){ e.parentNode.parentNode.removeChild(e.parentNode); } </script> </body> </html>
时间: 2024-10-14 00:56:03