/usblInPageAppendToClassMulti.js Secret
Last active
September 14, 2017 12:29
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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