私はHtml文字列を持っています。これをhtmlに解析して、pre
タグを削除してその子要素を削除します。html文字列内の要素をjQueryで削除する方法
HTMLString = "<p>a paragraph</p><p>second Paragraph</p><pre><script> function(){ something(); }</script></pre>";
var $jQueryObject = $($.parseHTML(HTMLString));
alert($jQueryObject.find('pre').length);
が、それはどんなpre
タグを見つけることができないことを意味し、このアラート私0: は、私はこれを試してみました。 誰でも自分のコードに何が問題なのか教えていただけますか?
HTMLString = "<p>a paragraph</p><p>second Paragraph</p><pre><script> function(){ something(); }</script></pre>";
var $jQueryObject = $($.parseHTML(HTMLString));
alert($jQueryObject.find('pre').length);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
短い説明は、この良い答えを完了します... –