Am trying to use Code Injections on Squarespace (asked there too, but no answer.) I need the value of a topdown list. However, each time I load the page, the ID changes. in this page load it is "yui_3_17_2_1_1549074579113_1343" On a subsequent load it will be different.
Do I need to invoke developer mode to lock it down? if now, how to do so? (if so, then code injections seem to be pretty useless as an option)
Sample code from what/where I need below.
Many grand thank yous'
Chris
<div class="variant-select-wrapper" data-text="Original+1"" id="yui_3_17_2_1_1549074579113_1343">
<select data-variant-option-name="Select Stem Size" id="yui_3_17_2_1_1549074579113_987">
<option value="">Select Select Stem Size</option>
<option value="Original-1.5"">Original-1.5"</option><option value="Original-1"">Original-1"</option><option value="Original-.5"">Original-.5"</option><option value="Original">Original</option><option value="Original+.5"">Original+.5"</option><option value="Original+1"">Original+1"</option><option value="Original+1.5"">Original+1.5"</option><option value="Original+2"">Original+2"</option>
</select>
</div>
As Brandon points out, "yui-..." ids are dynamic and you can't use them to identify an object.
There are a list of other types of ids, collection
, item
, page
, and block
(there are probably others). Any id starting with "collection-"
, "item-"
, "page-"
are safe to use. An id starting with "block-"
is safe, but an id starting with "block-yui"
may not be (there seems to be some debate about that on the squarespace forum).
Different templates have varying structures in how they use ids. I use a Brine based template and it has very few safe IDs. Some recommendations on dealing with that are Complex Selectors (here) and Attribute Selectors (here).