Forum Discussion
Create a button in the navigation bar on the right
ganeshsanap Yes, I'm trying to add this button for all modern pages.
I use SPFx Application Customizer and find the class (actionsWrapper-58) I need in order to add a new element (div with class new-link_box) to it.
const articleDiv = document.querySelector('.actionsWrapper-58');
const elem = document.createElement('div');
elem.classList.add('new-link_box');
articleDiv.insertBefore(elem, articleDiv.firstChild);
But, sometimes when I reload the page, this class can change from actionsWrapper-58 to actionsWrapper-90, in connection with this, the button does not always appear.
I found out that only these two class names alternate. Now I want to somehow search for this parent block, not by the entire name of the class, but only by the part up to the numbers (actionsWrapper).
Pavel48n0sh Use div selector like below:
const articleDiv = document.querySelector("div[class^='actionsWrapper-']");
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.