0

I am trying to add some buttons to SharePoint model dialog through Javascript but nothing seems to work. Following is my code.

     var htmlElement = document.createElement('p');
     var btnCancel = document.createElement("Button");
     btnCancel.className = 'Test';
     var txtCancel = document.createTextNode("Cancel");
     btnCancel.appendChild(txtCancel);
     htmlElement.appendChild(btnCancel);
     btnCancel.addEventListener("click", testFunction );

Is it possible to add elements dynamically to SharePoint model dialog?

Thanks.

2

In your code, you are creating an element, but you haven't appended it to anything in the DOM in order for it to show. You've appended your button to the paragraph that you created, but you never appended your paragraph (htmlElement) to anything that exists in the DOM.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.