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标签中 展开
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标签中 展开
3个回答
展开全部
<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>
<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>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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);
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);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<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>
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>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询