尝试使用:replace(/<[^<>]+?>/g,"").replace(/<[^<>]+?>/g,""),看看最后是不是就剩下文字了?

解决方案 »

  1.   

    <script>
      function f1()
     {
      alert(document.all.p1.innerText);
     }
    </script>
    <body onload="">
    <from id="form1" name="form1">
    <P id="p1" align=center><IMG src="xxx">要提取的文字</P>
    <input type="button" onclick=f1() value="sss"></form>
    </body>
      

  2.   

    <script language="javascript">
    <!--
    str = '<P align=center><IMG src="xxx">要提取的文字</P><P align=center><IMG src="xxx">要提取的文字</P>';
    re = /<p.+?<img.+?>(.+?)(<\/p>)/ig;
    alert(str.replace(re,"$1,"));
    //-->
    </script>
      

  3.   

    <script language="JavaScript">
    function test()
    {
    var str='<P align=center><IMG src="xxx">要提取的文字1</P><P align=center><IMG src="xxx">要提取的文字2</P>';
    var reg=/<.*?>/ig;
    alert(str.replace(reg,""))
    }
    test()
    </script>