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.addEventListener("click", testFunction );

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


1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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