Doubt with Jquery

0

IhavetheattachedimagewhenIclickonthecheckbox,Icanhighlightthislineviathefollowingcode:

$("input[type='checkbox']").change(function (e) {
    if ($(this).is(":checked")) {
        $(this).closest('tr').addClass("highlight_row");
    } else {
        $(this).closest('tr').removeClass("highlight_row");

    }
});

I'm tending to do that when I click two input fields that I have at the end they get the REQUIRED property. It must be something simple, but I'm skating about it. This is a line from where I can have 'n' lines.

    
asked by anonymous 09.04.2018 / 19:01

1 answer

0

Considering that $(this).closest('tr') is <tr /> . just use .find() to find inputs of type text . Example:

To add the required :

  • $(this).closest('tr').find('input[type=text]').attr('required', 'required');

or to remove required :

  • $(this).closest('tr').find('input[type=text]').removeAttr('required');
09.04.2018 / 19:30