I'm attempting to get all id's that contain a given string. The full id is not known, only a partial id. Id's appear like so:
<td class="item" id=shipping-1 align="left">$1.00</td>
<td class="item" id=shipping-2 align="left">$6.49</td>
<td class="item" id=shipping-3 align="left">$8.50</td>
// etc...
As you can see, "shipping-" is a constant, but the appended number is dynamic on page load (depends on what shipping options are valid for the receiving address).
I'm not great with javascript, but obviously using getElementById()
won't work here.
I would like to avoid doing something clunky like getting id's in a loop until I get an 'undefined'.
I need something like: getElementsContainingString('shipping-')
I need to get an array of these id's, then will read the innerHTML and determine which is cheapest. This must be done dynamically via javascript because we cannot control the page on the server side to perform this logic.