<book id="4" sortID="a4">
<title>author4aa</title>
<author>author4</author>
</book> 将上面这段代码复制到文本域,然后点击一个按钮,将title,和author的内容显示到另外两个文本框内,会的教下,谢谢。
QQ:380499906
<title>author4aa</title>
<author>author4</author>
</book> 将上面这段代码复制到文本域,然后点击一个按钮,将title,和author的内容显示到另外两个文本框内,会的教下,谢谢。
QQ:380499906
<input id=a>
<input id=t>
<input type=button value=set onclick="getData()"> <script>
function getData()
{
d = new ActiveXObject("MSXML2.DOMDocument")
d.loadXML(document.getElementById("x").value)
t=d.selectSingleNode("//title").text
a=d.selectSingleNode("//author").text
document.getElementById("a").value=a
document.getElementById("t").value=t
}
</script>
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="textEditor">
<META NAME="Author" CONTENT="theforever(碧海情天),赵亮">
<meta http-equiv="blog" content="blog.csdn.net/theforever">
<meta http-equiv="email" content="[email protected]">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<META NAME="Keywords" CONTENT="theforever,csdn,碧海情天,赵亮">
<META NAME="Description" CONTENT="碧海情天在csdn上的ID是theforever,这是我写的示例文档">
<TITLE></TITLE>
<style></style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function theforever() {
document.getElementById('s1').value=(/<title>([\s\S]+?)<\/title>/.exec(document.getElementById('t').value)[1]);
document.getElementById('s2').value=(/<author>([\s\S]+?)<\/author>/.exec(document.getElementById('t').value)[1]);
}
//-->
</SCRIPT>
</HEAD>
<BODY><textarea id=t>
<book id="4" sortID="a4">
<title>title-theforever</title>
<author>author-theforever</author>
</book>
</textarea>
<input type=text id=s1>
<input type=text id=s2>
<input type=button value="theforever" onclick="theforever();"></BODY>
</HTML>