I'm trying to add a class to an element that's created by Shopify's "Buy Button SDK". When I add it through the console it works fine, but it doesn't work when I run it through the attached .js document. It put in the alert and the color change for the H1 to make sure it's attached correctly, and it is.
Looking at other questions in this vein, it appears the script is trying to manipulate elements that aren't loaded yet. However, using either $(document).ready or $(window).on("load" have not worked. jQuery is called in the head, before the custom script.
$(window).on("load", function(){
alert("The page is reading the JavaScript");
$("h1").css("color", "orange");
$(".shopify-buy__product-img-wrapper").addClass("col-md-6");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.7.0/jquery.matchHeight-min.js"></script>
<script src="http://sdks.shopifycdn.com/js-buy-sdk/v0/latest/shopify-buy.umd.polyfilled.min.js"></script>
<script src="script.js"></script>