var boxmaterial = document.getElementsByClassName("spb-productoptiontextcolor spb-productoptionbackground")[0].value;
console.log(boxmaterial)
I have this code in a script but when I load the page I recieve
Uncaught TypeError: Cannot read property 'value' of undefined
at HTMLDocument.<anonymous> (product.js?2684207326912816513:14)
at u (vendor.js?2684207326912816513:14)
at Object.fireWith [as resolveWith] (vendor.js?2684207326912816513:14)
at ready (vendor.js?2684207326912816513:14)
This is because the field hasn't loaded yet since it is being loaded dynamically by a plugin. However when I run the code above in he console window while the page has loaded it works.
Is there a way to select the input and retrieve the value? You can see the page i am working on here working site