0

次のhtmlコンテンツがあります。

<div data-test='sectionA'>
    <input type="text" />
    <strong>sfdsfds</strong>
    <p>dffdfdsf</p>
</div>

上記の html コンテンツから要素strongと要素のみを複製する必要があります。pこれが私の試みです:

まず、セクションを特定する必要があります。

if($("div").data("test") == "sectionA")
{
     $(this).children().not("input").each(function()
     {
           alert($(this).html().clone());
           /* firefox says clone is not a function 
              and I'm not getting <strong>dfadfa</strong>
              or the <p>sfdasdfsd</p> clone copy */

      });
}
4

1 に答える 1

1
var $div =  $("div[data-test=sectionA]");
var $strong = $('strong', $div).clone();
var $p = $('p', $div).clone();
于 2013-02-10T20:45:26.413 に答える