-2
I hope this message finds you well.
I have a jquery code that performs table searches in real time. This code searches this table for cell values, but I need it to search at the same time for values and values of the title attribute.
Example if I have a company name in the table, it will find this company, however, if I own the company logo its name will be in the TITLE attribute and not as cell value. I need this code to search for both, both companies that only have the registered name and also those that have right in the table, but that the name is in TITLE.
Already anticipating my thanks, follow the code below.
Strong embrace to all!
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#example tfoot th').each(function() {
var title = $(this).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" />');
});
// DataTable
var table = $('#example').DataTable({
initComplete: function() {
// Apply the search
this.api().columns().every(function() {
var that = this;
$('input', this.footer()).on('keyup change clear', function() {
if (that.search() !== this.value) {
that
.search(this.value)
.draw();
}
});
});
}
});
});
</script>