JS <span>1<span> 替换为:<td>1</td> ?

JS 怎么把 <span>1<span> 替换为:<td>1</td>
谢谢!

斯蒂芬大帝
浏览 317回答 2
2回答

RISEBY

<html><head><title></title></head><body><script type="text/javascript">window.onload=function (){var str="<span>1</span>";var str_1=str.replace(/(<span>)(1)<\/span>/g,"<td>$2</td>");alert(str_1);}</script></body>不知道这样是不是你所描述的那样呢????

哔哔one

var&nbsp;oldStr&nbsp;=&nbsp;"<span>1<span><span>1<span>";//var&nbsp;newStr&nbsp;=&nbsp;oldStr.replace("<span>1<span>","<td>1</td>");&nbsp;//替换第一个var&nbsp;newStr&nbsp;=&nbsp;oldStr.replace(eval("/<span>1<span>/g"),"<td>1</td>");&nbsp;//替换所有
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
Html5