Skip to content

Instantly share code, notes, and snippets.

@lennardtastic
Last active September 14, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lennardtastic/3de23b3ad887684d76da4bd238711329 to your computer and use it in GitHub Desktop.
Save lennardtastic/3de23b3ad887684d76da4bd238711329 to your computer and use it in GitHub Desktop.
/**
* Function for appending multiple Usabilla InPage widget on one page based on a provided classname.
* Use this function use this function after page-load, before the function usblInPageAddCustomVarMulti and before the in-page install script.
* @param {String} classname [The name of the Class you want to us for appending the in-page widgets (no special characters or uppercase)]
* @param {String} widgetid [The ID of the widget you want to use found on https://app.usabilla.com/member/live/in-page/widget]
*/
function usblInPageAppendToClassMulti(classname, widgetid){
var faqToggleElementList = document.getElementsByClassName(classname);
var arrayLengthFaqToggle = faqToggleElementList.length;
var nodeDiv = document.createElement("div");
nodeDiv.setAttribute("ub-in-page", widgetid);
for (var i = 0; i < arrayLengthFaqToggle; i++) {
faqToggleElementList[i].appendChild(nodeDiv.cloneNode(true));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment