如何删除p br

时间:2012-08-28 04:21:07

标签: jquery

从波纹管代码如何通过jquery或php删除所有p和br。

<div id="wpwhoisinside-2">
<div class="swWrap" id="wpwhoisdiv">
<form method="post" style="margin: 0px;" action="#void" onsubmit="wpwhoisform('2'); return false;" name="wpwhoisform2" id="wpwhoisform2">
<p>                         <input type="hidden" id="wpwhoiswidget2" value="Y" name="widget"><br>
                <input type="hidden" value="2" name="number"></p>
<div class="swForm">
                <input type="text" onfocus="this.select();" value="domain" class="swDomain" name="domain" id="wpwhoisdomain2"><br>
                                    <b>.</b><p></p>
<select name="tld" class="swtld">
<option selected="" value="com">com</option>
<option value="com.sg">com.sg</option>
<option value="com.my">com.my</option>
<option value="cl">cl</option>
<option value="ch">ch</option>
<option value="se">se</option>
<option value="net">net</option>
<option value="org">org</option>
<option value="info">info</option>
<option value="biz">biz</option>
<option value="us">us</option>
<option value="co.uk">co.uk</option>
<option value="org.uk">org.uk</option>
<option value="org.my">org.my</option>
<option value="ltd.uk">ltd.uk</option>
<option value="ca">ca</option>
<option value="cc">cc</option>
<option value="edu">edu</option>
<option value="com.au">com.au</option>
<option value="net.au">net.au</option>
<option value="net.my">net.my</option>
<option value="de">de</option>
<option value="ws">ws</option>
<option value="sc">sc</option>
<option value="nl">nl</option>
<option value="be">be</option>
<option value="eu">eu</option>
<option value="co.il">co.il</option>
<option value="co.th">co.th</option>
<option value="org.il">org.il</option>
<option value="mobi">mobi</option>
<option value="asia">asia</option>
<option value="tel">tel</option>
<option value="me">me</option>
<option value="my">my</option>
<option value="tv">tv</option>
<option value="mx">mx</option>
<option value="co.za">co.za</option>
<option value="fr">fr</option>
<option value="ie">ie</option>
<option value="it">it</option>
<option value="jp">jp</option>
</select>
<div class="wpwhoissecureimage">
        8 + 7 =     <input type="text" value="" style="width:25px; font-size:10px; font-weight:bold;" name="total"><br>
        <input type="hidden" value="9bf31c7ff062936a96d3c8bd1f8f2ff3" name="hashtotal">
        </div>
<div><input type="submit" class="swSubmit ui-button ui-widget ui-state-default ui-corner-all" value="Check Domain" name="lookup" role="button" aria-disabled="false"></div>
<div class="swInfo"></div>
<p></p></div>
<p></p></form>
<p></p></div>
<p><script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('.swSubmit').button();
});
</script></p>
</div>

我试过这个

<script language='javascript'>
$("#wpwhoisinside-2 p").remove();
$("#wpwhoisinside-2 br").remove();

</script>

但是对于像<input type="hidden" id="wpwhoiswidget2" value="Y" name="widget">这样的内部p内容也会删除。但我只是想删除p和br标签没有别的..你们可以帮助我吗?

感谢

1 个答案:

答案 0 :(得分:3)

尝试:

$("#wpwhoisinside-2 p > *").unwrap("<p></p>");
$("#wpwhoisinside-2 br").remove();

除此之外,如果你想删除空的p标签,那么,添加到第二行:

$("#wpwhoisinside-2 br, p:empty").remove();