Black and White Black and White - 6 months ago 20
jQuery Question

Adding an Attribute COLSPAN using Javascript Using an data-id Tag

Good Day! I am only new in programming javascript I have this problem theres a table Tag with a Theader with an Attribute of data-id now I just want to add a Colspan Dynamically using this data-id tag to find the specific Column to add a COLSPAN attribute

I've created this code of mine


This is to remove a table header in a Table in Javascript, and try to use the following code to add some attribute.

$('th[data-id="param_name_1_value"]').createAttribute("colspan", "9");

But theres an error, is it possible to add an Attribute via data-id?



You can set attribute like this:

$('th[data-id="param_name_1_value"]').attr("colspan", "9");