I’m trying to apply a tooltip to a foreach loop, but I need the javascript to read the attribute “mystickytooltip” with a number at the end.
<div id="mystickytooltip{$smarty.foreach.cart.iteration}" class="stickytooltip">
Will output
<div id="mystickytooltip1" class="stickytooltip">
<div id="mystickytooltip2" class="stickytooltip">
<div id="mystickytooltip3" class="stickytooltip">
And I need the javascript to read “mystickytooltip(ANYVALUE)” is this possible? My JS knowledge sucks.
//stickytooltip.init("targetElementSelector", "tooltipcontainer")
stickytooltip.init("*[data-tooltip]", "mystickytooltip")
Thanks.
In your previous (now deleted) question, it looked like you were using jQuery. If that’s the case, you should just be able to use a class selector:
Or you could use the
Attribute Starts Withselector:The only possible drawback I could forsee with the attr-starts-with selector is if you have any other div elements whose id begins with “mystickytooltip” (ie, “mystickytooltipcontainer”). In that case you could combine the class and attr-starts-with selectors: