<input type=button onclick="if(a>b)alert()">要看写得多复杂了,也得简单点的话<input type=button onclick="if(a>可以会被认为是一个标签...其它的都会当成内容过滤掉了...

解决方案 »

  1.   

    不考虑xiao7cn的那种情况了。当word转成html时,a>b都变成a&gt;b了。
      

  2.   

    /\<p(.*?)\>[\s\S]*?\<\/p\>/
      

  3.   

    支持hb!
    <p[^</p>][\s|\S]*?</p>
      

  4.   

    /\<p(.*?)\>[\s\S]*?\<\/p\>/和<p[^</p>][\s|\S]*?</p>都可以匹配p里的内容。如果p有换行的class之类的,/\<p(.*?)\>[\s\S]*?\<\/p\>/改成 \<p[\s\S]*?\>[\s\S]*?\<\/p\>就行了.
    我想取得所有的table,tr,td标签,如果td的标签里有colspan、width、height属性,则极然保留colspan、height、width属性。
    s = "<div class=Section1 style='layout-grid:15.6pt'....";
    s = s.replace(/\<p[\s\S]*?\>[\s\S]*?\<\/p\>/gi,'');
    s = s.replace(/\<table[^</table>][\s\S]*?\>/gi,'<table>\n');
    s = s.replace(/\<tr[^</tr>][\s\S]*?\>/gi,'<tr>\n');
    str = s.replace(/\<td[^</td>][\s\S]*?\>/gi,'<td>\n');
    st.innerText = str;
    这样无法保留colspan等属性
      

  5.   

    str = s.replace(/(\<td[^>]*?\>)[\s\S]*<\/td>/gi,'$1<\/td>\n');
      

  6.   

    飘过...
    我敬爱的斑竹哥哥...帮我看看这个帖子呗..
    to hbhbhbhbhb1021(天外水火(我要多努力))地址:
    http://community.csdn.net/Expert/topic/5311/5311802.xml?temp=.1383936