Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Register a callback that fires when an element is added to the DOM.

let unobserve = window.optimizelyEdge.get("utils").observeSelector("#cta", function(ctaElement) {
  ctaElement.innerText = "Click me!";
  unobserve();
});

Parameters

ParameterTypeDescription
selector
required
stringA CSS selector indicating the element to wait for.
callback
required
functionThe function that will be executed each time an element is added to the DOM that matches the selector. The first argument is the exact node that is added.

Returns

ParameterTypeDescription
unobservefunctionA function that can be executed to stop observing.