0

I had a disable button so I need specific data row change to grey color and disable when i click disable button. In my code i can only disable a button. Please help.

 $('#domain_table').DataTable({
        "processing": true,
        "serverSide": true,
        "scrollX": true,
        "ajax": "{{ route('ajaxdomain.getdata') }}",
        "columns":[
            { "data": "Domain" },
            { "data": "Registrar" },
            { "data": "action", orderable:false, searchable: false}
        ]
    });

      $(document).on('click', '.delete', function(){
        var No = $(this).attr('No');
        if(confirm("Are you sure you want to disable this data?"))
        {
            $.ajax({
                url:"{{ route('ajaxdomain.removedata') }}",
                method:"POST",
                data:{No:No},
                success:function(data)
                {
                    alert(data);
                    $('#domain_table').DataTable().ajax.reload();
                }
            })

            if(this.style.background == "" ) {
                $(this).css('background', 'lightgrey');
            }
            else {
                $(this).css('background', '');
            }
        }
        else
        {
            return false;
        }
    });
JoSSte
  • 2,953
  • 6
  • 34
  • 54
user9912010
  • 107
  • 2
  • 8

1 Answers1

1

Try this to change background on selection;

$(this).closest('tr').css('background-color', 'lightgrey');
ThivankaW
  • 511
  • 1
  • 8
  • 21