通过 如下正则表达式可以替换dom元素中的标签
/<[\/]?(div)([^<>]*)>/g
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="UTF-8">
<title></title>
<script src="jquery.min.js"></script>
</head>
<body>
<div id="abc">
<div style="text-align: center;">
test
</div>
</div>
</body>
<script> var oriTest = $("#abc").html(); var result = oriTest.replace(/<[\/]?(div)([^<>]*)>/g,function (m,m1) { console.log(m); return m.replace('div','p'); }); $("#abc").html(result); </script>
</html>