I am using Vite where I store the image's source in the css. In a function, I have to get the source of the image but I am not sure how to pull it from the css. Below is how I selected the img tag and how I stored the img source. How would I write this out in Javascript to put the css content in the array?
// JS
this.images = [...document.querySelectorAll('img')];
//css
#firstimage {
  content: url(./assets/img1.jpg);
}
#secondimage {
  content: url(./assets/img1.jpg);
}
				
                        
The OP needs to
filtereach image-element of the queried images-onlyNodeList(after casting it into an array type) by its computedcontentstyle-property with the help ofwindow.getComputedStyle.Edit ... due to the fact that the above (initial) answer missed one (the most important) of the OP's requirements.
The firstly provided solution then needs to be changed from a
filterto areducetask where one (as for the former) not just doestestthecontentvalue by a simple regex like ...^url\(.+\)$... but also (as for the latter) captures the image-source by a regex like ...^url\((?<src>.+)\)$... which features a named capturing group.