Ecommerce Shopify WordPress Discussion

Wrapping jQuery in a new, dynamically created Div

Trying to get dynamically generated tooltips to be created within a grid. Currently they are appended to the body and I have to start by getting them in a wrapper, so I can define display:grid; This is the code snippet and its appended to the body right after this. I have tried concatenating the wrapper div, but as $tooltip is called later, the functions try to run on the newly created div. I also tried .wrap & .wrapAll but didn't have any luck. r.$tooltip = e( '<div id="' + r.options.ult_adv_id + '" class="ult-tooltipster-base ' + r.options.theme + '" style="' + BaseStyle + '"><div class="ult-tooltipster-content ult-responsive" data-ultimate-target="' + r.options.ultimate_target + '" data-responsive-json-new = \'' + r.options.responsive_json_new + '\' style="' + contentStyle + '"></div></div>' ); Output: <body> <div id="hotspot-tooltip-hs-three" class="ult-tooltipster-base ult-tooltipster-default"> ########## </div> </body> Trying to achieve: <body> <div id="hotspot-grid"> <div id="hotspot-tooltip-hs-three" class="ult-tooltipster-base ult-tooltipster-default"> ########## </div> </div> </body> I tried concatenating the new div: r.$tooltip = e( '<div id="hotspot-grid"><div id="' + r.options.ult_adv_id + '" class="ult-tooltipster-base ' + r.options.theme + '" style="' + BaseStyle + '"><div class="ult-tooltipster-content ult-responsive" data-ultimate-target="' + r.options.ultimate_target + '" data-responsive-json-new = \'' + r.options.responsive_json_new + '\' style="' + contentStyle + '"></div></div></div>' ); Which worked for display purposes and the div is where I wanted if but as the newly created div is included in the variable for $tooltip, other functions later in the script are running using this and not the child div (which was of course previously the parent). Then I tried .wrap & .wrapAll : r.$tooltip = e( '<div id="' + r.options.ult_adv_id + '" class="ult-tooltipster-base ' + r.options.theme + '" style="' + BaseStyle + '"><div class="ult-tooltipster-content ult-responsive" data-ultimate-target="' + r.options.ultimate_target + '" data-responsive-json-new = \'' + r.options.responsive_json_new + '\' style="' + contentStyle + '"></div></div>' ).wrapAll( document.createElement( "div" ) ); then I tried .wrap & wrapAll further on down (before r.$tooltip.appendTo('body'); ) r.$tooltip = e( '<div id="' + r.options.ult_adv_id + '" class="ult-tooltipster-base ' + r.options.theme + '" style="' + BaseStyle + '"><div class="ult-tooltipster-content ult-responsive" data-ultimate-target="' + r.options.ultimate_target + '" data-responsive-json-new = \'' + r.options.responsive_json_new + '\' style="' + contentStyle + '"></div></div>' ); if (l()) r.$tooltip.addClass(o); r._content_insert(); ( 'ult-tooltipster-base' ).wrap("<div class='hotspot-grid'></div>"); r.$tooltip.appendTo('body'); And of course none of these worked. I also created the new div on the page in HTML so it would exist,and tried to change r.$tooltip.appendTo('body'); to r.$tooltip.appendTo('body'); but also, No Bueno.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.