js 查找字符串 并把指定的字符插入查找到的字符后边

varfoot="<divid='foot_bar'>";foot+="<spanclass='123'></span>";foot+="</div>";$(body).... var foot = "<div id='foot_bar'>";
foot += "<span class='123'></span>";
foot += "</div>";

$(body).append(foot);

如何把:
<iframe frameborder=0 width=332 height=205 marginheight=0 marginwidth=0 src="" scrolling="auto"></iframe>
追加到div标签中
展开
 我来答
我爱美美的
推荐于2016-03-27 · 超过29用户采纳过TA的回答
知道答主
回答量:92
采纳率:0%
帮助的人:70.5万
展开全部
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script src="../DEMO/jquery-1.6.4.js" type="text/javascript"></script>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
$(function(){
var foot = "<div id='foot_bar'>";
foot += "<span class='123'></span>";
foot += "</div>";// 这里可以写在add_frame后面,具体看你用那种方便。
var add_frame="<iframe frameborder=0 width=332 height=205 marginheight=0 marginwidth=0 src='' scrolling='auto'></iframe>";
$("body").append(foot);
$("#foot_bar").append(add_frame);

alert($("body").html());
// 执行后的结果
//<div id="foot_bar"><span class="123"></span>
//<iframe marginheight="0" marginwidth="0" src="" scrolling="auto" frameborder="0" height="205" width="332"></iframe>
//</div>
}); // 结束
</SCRIPT>
</head>
<body>
</body>
</html>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
R夏至未至H
2011-09-14 · TA获得超过469个赞
知道小有建树答主
回答量:273
采纳率:100%
帮助的人:351万
展开全部
var newfoot = foot;
var frameContent = "<iframe frameborder=0 width=332 height=205 marginheight=0 marginwidth=0 src='' scrolling='auto'></iframe>";
var length = newfoot.length;
newfoot =foot.substring(0,length-5);//去掉结束标签:</div>
foot = newfoot+frameContent+"</div>";//添加插入内容并加上结束标签:</div>
$(body).append(foot);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
源念云F
2011-09-14 · TA获得超过685个赞
知道小有建树答主
回答量:298
采纳率:0%
帮助的人:291万
展开全部
<script type="text/javascript">
var foot = "<div id='foot_bar'>";
foot += "<span class='123'></span>";
foot += "</div>";
var toAppend = '<iframe frameborder=0 width=332 height=205 marginheight=0 marginwidth=0 src="" scrolling="auto"></iframe>';
var replaceAsFirstElement = foot.replace(/(<span\s+.*?>.*?<\/span>)/,"$1"+toAppend);
var replaceAfterFirstElement = foot.replace(/(<span\s+.*?>.*?<\/span>)/,toAppend+"$1");
document.write(replaceAsFirstElement);
document.write(replaceAfterFirstElement);
</script>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式