Link to home
Start Free TrialLog in
Avatar of jabz ayuap
jabz ayuap

asked on

how can I disable button if table row appended was Empty?

I have a create button which disabled at first I want to enable it when the table row has a record, how can i do this? I have jquery here, how can I improved this?

 $("#btnCreateExecutiveShareList").click(function () {
         
            var numberOfRows = $('#AppendedTableEmployeeShare > tbody > tr').length;
            if (numberOfRows == 0 || numberOfRows == "") {
                $("#btnCreateExecutiveShareList").attr("disabled", true)
            }
            else
            {
                $("#btnCreateExecutiveShareList").attr("disabled", false)
            }
        });
ASKER CERTIFIED SOLUTION
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jabz ayuap
jabz ayuap

ASKER

Hi randy what if the number of rows = 0 and the button disabled what if i remove the value, how can i disable it again?