Add class to image in Squarespace using javascript or jquery -
i thought easy. added code injection header.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script>$("img").addclass("example")</script>
the scripts appear in page source, have no effect adding class images. i've tried specific div classes , ids, , other script variations, again no effect.
does squarespace somehow prevent assigning classes? image i'm trying target has no class assigned it. squarespace gives every element unique id, these can't selected because change every time page loaded.
you should this:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(function() { $("img").addclass("example") }) </script>
the $(function() {})
wait till document loaded , call function inside.
Comments
Post a Comment