0

I have a dynamic table based on a python dataframe and I added to the 2nd and 23rd column the following classes:

 $(".tablafiltros tbody tr td:nth-child(2)").addClass('ColNodo');
 $(".tablafiltros tbody tr td:nth-child(23)").addClass('ColGest');

I have also assigned to .ColGest the following attr:

        $(".ColGest").attr("data-pk","index")

By this way I am adding the same fixed attribute "data-pk" = "index" to every in ".ColGest", but what I need is to assign to each ".ColGest" an attribute that is the content of the .ColNodo (the cell value)

Thanks in advance.

1
  • Hi, is this issue solve ? Commented Jan 31, 2021 at 12:22

1 Answer 1

1
// Loop over all .ColGest items
$('.ColGest').each(function(index) {

   // get the ColNodo cell with same index as the current ColGest in the loop
   const colNodoValue = $('.ColNodo')[index].text();

   // add a data-value attribute with the colNodo value
   $(this).attr("data-value", colNodoValue);

});

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.