html - PHP print message when a div is present on specific page

one text

Solution:

Due to the information you've provided I guess using JavaScript on the client-side would be your way to go.

document.addEventListener("DOMContentLoaded", () => {
    const sizeChartTabEle = document.querySelector("div#tab-SizeChart_tab")
    const storleksGuideLinkEle = document.createElement("a")
    storleksGuideLinkEle.title = "Storleksguide"
    storleksGuideLinkEle.href = "#tab-SizeChart_tab"
    storleksGuideLinkEle.classList.add("size_guide_link")
    storleksGuideLinkEle.innerText = "Storleksguide"
    sizeChartTabEle?.append(storleksGuideLinkEle)
})

This code creates an event listener DOMContentLoaded (see this StackOverflow answer to learn more about it, speaking very basic - it waits for your contents being loaded) and executes the part in the curly brackets.

Your div#tab-SizeChart_tab is queried and afterwards appended by a newly created a element storleksGuideLinkEle.

If you make sure this code is only executed on pages that you need it, this should do the job.

Source