Skip to main content
adicionou 17 caracteres ao conteúdo
Fonte Link
Sergio
  • 135,1mil
  • 16
  • 201
  • 294

Se quiseres usar somente o ultimo fieldset podes usar :last-child assim:

var fieldset = document.querySelector('fieldset'#BlocosDinamicos fieldset:last-child');
document.getElementById("CopiaUltimoConteudo").innerHTML = fieldset.innerHTML;
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Se quiseres de todos os fieldset podes fazer assim:

var fieldsets = document.querySelectorAll('#BlocosDinamicos fieldset');
document.getElementById("CopiaUltimoConteudo").innerHTML = [].map.call(fieldsets, function(el){ return el.innerHTML}).join('');
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Se quiseres usar somente o ultimo fieldset podes usar :last-child assim:

var fieldset = document.querySelector('fieldset:last-child');
document.getElementById("CopiaUltimoConteudo").innerHTML = fieldset.innerHTML;
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Se quiseres de todos os fieldset podes fazer assim:

var fieldsets = document.querySelectorAll('#BlocosDinamicos fieldset');
document.getElementById("CopiaUltimoConteudo").innerHTML = [].map.call(fieldsets, function(el){ return el.innerHTML}).join('');
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Se quiseres usar somente o ultimo fieldset podes usar :last-child assim:

var fieldset = document.querySelector('#BlocosDinamicos fieldset:last-child');
document.getElementById("CopiaUltimoConteudo").innerHTML = fieldset.innerHTML;
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Se quiseres de todos os fieldset podes fazer assim:

var fieldsets = document.querySelectorAll('#BlocosDinamicos fieldset');
document.getElementById("CopiaUltimoConteudo").innerHTML = [].map.call(fieldsets, function(el){ return el.innerHTML}).join('');
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Fonte Link
Sergio
  • 135,1mil
  • 16
  • 201
  • 294

Se quiseres usar somente o ultimo fieldset podes usar :last-child assim:

var fieldset = document.querySelector('fieldset:last-child');
document.getElementById("CopiaUltimoConteudo").innerHTML = fieldset.innerHTML;
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>   

Se quiseres de todos os fieldset podes fazer assim:

var fieldsets = document.querySelectorAll('#BlocosDinamicos fieldset');
document.getElementById("CopiaUltimoConteudo").innerHTML = [].map.call(fieldsets, function(el){ return el.innerHTML}).join('');
    <h3>Multiplos Fieldsets</h3>
        <br>
        <div id="BlocosDinamicos">
            <fieldset><legend></legend>
                <p>Conteudo 1</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 2</p>
            </fieldset>
            <fieldset><legend></legend> 
                <p>Conteudo 3</p>
            </fieldset>
        </div>
        <hr />
        <div id="CopiaUltimoConteudo"></div>