Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda