how to capture the click event of the span

0

I have the following javascript function:

function LoadDataTable(data) {     

          $('#table-labresult').bootstrapTable("load", data);
          $table.bootstrapTable('refreshOptions', {
                pageSize: 5,                    
                columns: [{}, {}, {}, {}, {}, 
                {
                    field: 'download',
                    title: 'Export',
                    align: 'center',
                    valign: 'middle',
                    clickToSelect: true,
                    width: '5%',
                    formatter: function (value, row, index) {
                        return '<span RecNo="' + row.RecNo + '" IsFileCompress="' + row.IsFileCompress + '" class="glyphicon glyphicon-download-alt downl"></span>';

                    }
                }
                ]
            });         
        }

What I would need is when I click on the span me even if it's a console.log (Recno);

How can I get that attribute when I click on the span?

probe with this:

onclick="clickdownload($this.RecNo)"

This gives me an error and tells me that clickdownload is not defined, and if it is defined

    
asked by Raidel Fonseca 23.07.2018 в 16:00
source

2 answers

1

You can try this variant when you use datatables:

$('#table-labresult tbody').on( 'click', '#span', function () {
        console.log('Click on Span');

});
    
answered by 23.07.2018 в 16:32
0

Use an ID attribute in your span :

And in the jquery:

<script>

        $("#span").click( function()
           {
             console.log(Recno);
           }
        );
</script>
    
answered by 23.07.2018 в 16:10