If Element has jquery add attr element

Last Updated On Monday 30th May 2022

jquery addattr

  • Takes an attribute argument and a value argument in the form of strings.
  • Adds the attribute, and the value provided, to all elements in the DOMNodeCollection. Equivalent to jQuery’s attr('attribute', 'value') function.
	let something = $selected.addAttr('color', 'green');
	

Adds the 'color' attribute with the value of 'green' to each element in the selected DOMNodeCollection.