Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
How to find element from html with jQuery

I have a table with checkbox option for each row.

For each row I have href (dedicated link) handled by HTML file.

I have created a button called: "download" by JS, and I want to define this button to save all the links for the rows which have selected in the checkboxes, and save it in one variable, selectedLinks = []

Any idea how can i fix my JS function.

//function download button

$(document).on("click", "#downloadBtn", function() {
console.log("download button click")
var selectedLinks = []
$('.last')
    .checkSingel("checkSingle")
    .forEach(function(record) {
        if (record.checked) {
            //selectedLinks.push(record.href)
            alert($(this).attr("href"));
        }
    })
console.log(selectedLinks)
});
</td>
<td class="last"><a style="font-weight:bold;text-decoration:underline;" href="/download/{{ elements.EvidencePath }}">Click here to download Evidence</a>
</td>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

this is the proper code :

        // function to add multiple check box for all rows

        $(document).on("click", ".checkAll", function(){
           $('input:checkbox').not(this).prop('checked', this.checked);
           // this statement is checked it will enable the download button ( for check all button)
           if(this.checked) {

               $(".dt-buttons a:last-child").removeAttr("disabled");
           }else {
            $(".dt-buttons a:last-child").attr("disabled", "disabled");
           }
        });
        
        // this statement is checked to eanbled the  button if the checkbox checked. ( for check single button)
        $(document).on("click", ".checkSingle", function(){

           if(this.checked) {

               $(".dt-buttons a:last-child").removeAttr("disabled");
           }else {
            $(".dt-buttons a:last-child").attr("disabled", "disabled");
           }
        });

//function download button

            $(document).on("click", "#downloadBtn", function(){
                console.log("download button click")
                var selectedLinks = []

            $('.last').checkSingel("checkSingle").forEach(function(record){
                if (record.checked){
                    //selectedLinks.push(record.href)
                    alert($(this).attr("href"));
                }
            })
                console.log(selectedLinks)
        });

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda