js 使用正则去除属性

//比如有一个input是这样的
var _html="<input id='txt_TextBox1' type='text' date-col='a' class='txt read-only' date-replace='txt_' date-type='TextBox' readonly='readonly'  date-c='自定义校验' style='width: 90%;height: 22px;background: rgb(168, 168, 168)' />"
//我们可以这样去除date-col属性
_html=_html.replace(/date-col='.*?'/g, '');

然后得到的 _html,我们可以用$('#id').append(_html); 放到任意元素下

posted @ 2018-01-10 12:45  伏地魔程序员  阅读(521)  评论(0编辑  收藏  举报