<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function matchText()
{
    var say=document.getElementById("inputText").value;

     var x=document.getElementsByTagName("p");
 
     document.writeln(x[0].innerHTML.replace(say,"<font color=red>"+ say +"</font>"));
   document.write(x[1].innerHTML.replace(say,"<font color=red>"+ say +"</font>"));
   document.writeln(x[2].innerHTML.replace(say,"<font color=red>"+ say +"</font>"));
   document.writeln(x[3].innerHTML.replace(say,"<font color=red>"+ say +"</font>"));
  

}
</script>
</head><body>
<p >www.51js.ccm</p>
<p >bbs.51js.com</p>
<p >Javascript is not Java</p>
<p >Javascript is fun and I like Javascript</p>
<label>
  <input type="text" name="textfield" id="inputText" />
</label>
  <label>
  <input type="button" name="Submit" value="提交" onclick="matchText()" />
  </label>
</p>
</body>
</html>

解决方案 »

  1.   

    Can You Tell Me:what did you want to do?
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    function matchText()
    {
      var say=document.getElementById("inputText").value;  var x=document.getElementsByTagName("p");
      for(var i=0;i<x.length;i++)
        x[i].innerHTML = x[i].innerHTML.replace(say,"<font color=red>"+ say +"</font>");
    }
    </script>
    </head><body>
    <p >www.51js.ccm</p>
    <p >bbs.51js.com</p>
    <p >Javascript is not Java</p>
    <p >Javascript is fun and I like Javascript</p>
    <label>
      <input type="text" name="textfield" id="inputText" />
    </label>
      <label>
      <input type="button" name="Submit" value="提交" onclick="matchText()" />
      </label>
    </p>
    </body>
    </html>
      

  3.   

    就是实现用javascript通过匹配更换当前页面中的内容
      

  4.   

    <html>
    <head>
    <script type="text/javascript">
    function alertValue()
      {
      alert(document.getElementById("text1").value)
      }
    </script>
    </head>
    <body><form>
    <input type="text" id="text1" value="Hello world!" />
    <input type="button" id="button1" onclick="alertValue()" value="Show default value" />
    </form></body>
    </html>
    你是想要这样的效果吗?
      

  5.   

    js里面  怎么实现加等?
    (var num = document.getElementById("count").value;
    num += 1;)这里的加等是字符串相加了,应该怎么写?  求解
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title><script type="text/javascript">
    function matchText()
    {
      var say=document.getElementById("inputText").value;
    for(i=0;i<document.getElementsByTagName("p").length;i++){
      document.getElementsByTagName("p")[i].innerHTML=say; 
    }
    }
    </script></head><body>
    <p>www.51js.ccm</p>
    <p>bbs.51js.com</p>
    <p>Javascript is not Java</p>
    <p>Javascript is fun and I like Javascript</p>
    <p>Java is fun and I like Javascript</p>
    <p>php is fun and I like Javascript</p>
    <label>
      <input type="text" name="textfield" id="inputText" value=""/>
    </label>
      <label>
      <input type="button" name="Submit" value="提交" onclick="matchText()" />
      </label></body>
    </html>这个应该是LZ想要的效果