Search code examples
javascriptsquarespace

Changing button text through JS?


I'm using Squarepace.

I'm trying to change the word 'authenticate' here

This is the script:

document.title = "McCann Show & Tell - Please enter the password :)";
document.body.style.background = "#f7a2cc  url('https://dl.dropboxusercontent.com/u/46025079/pattern.jpg') repeat";
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("yui_3_17_2_1_1418836557893_299").value = "hello";
}, false);

This is the part that atttempts to change the button text

document.addEventListener('DOMContentLoaded', function() {
document.getElementById("yui_3_17_2_1_1418836557893_299").value = "hello";
}, false);

I can't seem to get it working


Solution

  • The id of that button constantly changes, so you need to use a different selector.
    You could try:

    document.querySelectorAll('input[type=button]')[0].value = 'hello';
    

    or

    document.getElementsByClassName('saveAndClose')[0].value = 'hello';