Home > Blockchain >  When a datatable (jquery) has data after getting filtered, make a label visible
When a datatable (jquery) has data after getting filtered, make a label visible

Time:12-09

I have a DataTable (jQuery) that currently allows me to filter my data when I enter a string inside an input field. By default, a label is invisible.

After filtering, I want to be able to make a the label visible if the the dataTable after filtering contains data. Vice versa, if the dataTable is empty after filtering, I want the label to stay invisible.

I am relatively new to web-development so please excuse my lack of knowledge. The filtering of the datatables is client-side so im a but unsure on how to achieve this.

this is how i initialised the datatable

if the filter results in an empty dataTable, no label should appear

if the filter results in a datatable with data, a label should appear

CodePudding user response:

You need to add a change event listener to your input field. Afterwards just check if the field content meets the required conditions and set the label's display style to style properties like

document.getElementById(labelname).style.display = 'none'
  • Related