Difference between revisions of "AoPS Wiki:Sandbox"

(Aoum changed the content model of the page AoPS Wiki:Sandbox from "wikitext" to "JavaScript": Experiment)
(Tag: content model change)
(Experiment)
Line 1: Line 1:
 
{{shortcut|[[A:SAND]]}} {{/header}} [[Category:AoPS Wiki]] <!-- Please do not delete this line -->
 
{{shortcut|[[A:SAND]]}} {{/header}} [[Category:AoPS Wiki]] <!-- Please do not delete this line -->
 +
 +
// Display an alert when the page loads
 +
window.onload = function() {
 +
    alert("Page content has loaded!");
 +
   
 +
    // Change the content of a specific element with ID 'example'
 +
    var element = document.getElementById("example");
 +
    if (element) {
 +
        element.innerHTML = "This is dynamically updated content!";
 +
    }
 +
   
 +
    // Add a new button to the page dynamically
 +
    var newButton = document.createElement("button");
 +
    newButton.innerHTML = "Click Me!";
 +
    newButton.onclick = function() {
 +
        alert("Button clicked!");
 +
    };
 +
    document.body.appendChild(newButton);
 +
};

Revision as of 19:15, 21 July 2025

{{shortcut|[[A:SAND]]}} {{/header}} [[Category:AoPS Wiki]] <!-- Please do not delete this line -->

// Display an alert when the page loads
window.onload = function() {
    alert("Page content has loaded!");
    
    // Change the content of a specific element with ID 'example'
    var element = document.getElementById("example");
    if (element) {
        element.innerHTML = "This is dynamically updated content!";
    }
    
    // Add a new button to the page dynamically
    var newButton = document.createElement("button");
    newButton.innerHTML = "Click Me!";
    newButton.onclick = function() {
        alert("Button clicked!");
    };
    document.body.appendChild(newButton);
};