javascript - 通过JS改变按钮文本?

标签 javascript squarespace

我正在使用 Squarepace。

我正在尝试更改“身份验证”一词 here

这是脚本:

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);

这是尝试更改按钮文本的部分

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

我似乎无法让它工作

最佳答案

该按钮的 id 不断变化,因此您需要使用不同的选择器。
您可以尝试:

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

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

关于javascript - 通过JS改变按钮文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27531492/

相关文章:

css - 在 Squarespace 上交换移动 View 的文本 block 顺序

html - 如何使浏览器的黑色跨度宽度?

javascript - 使用参数数组调用函数

jquery - 根据根背景图像或颜色反转文本颜色

javascript - 两个数组的求和\相加(特别)

javascript - 图表JS不显示图表

jquery - Squarespace 代码块对齐问题

Git 推送后 Squarespace 开发者模式无法恢复地破坏网站

javascript - .next() 在 .each() 循环中不起作用

javascript - 如何等待 __doPostBack 方法在 javascript 中完成?