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;
        }
    });
2
  • Please be more clear about your question. Commented Jan 3, 2019 at 8:22
  • Hi @Aika, I had a disable button on every data row. I want the data row change to grey color when i click the disable button on the specific data. Commented Jan 3, 2019 at 8:28

1 Answer 1

1

Try this to change background on selection;

$(this).closest('tr').css('background-color', 'lightgrey');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.