替换网站中的Word?

时间:2016-02-15 23:48:48

标签: javascript html greasemonkey

您好我在使用greasemonkey,我已经创建了一些具有不同功能的基本按钮。这次我决定做其他事情,那就是将网站中的某个文本替换为其他内容。我有一些图片显示了我想要改变的内容。

Div:http://prntscr.com/a3skwz

要替换的文字:http://prntscr.com/a3sl5b

按钮样式:http://prntscr.com/a3sldq

代码:http://prntscr.com/a3slq1

var input=document.createElement("input");
input.type="button";
input.value="Change";
input.onclick = buttononclick;
input.setAttribute("style", "font-size:18px;position:absolute;top:300px;right:170px;");
document.body.appendChild(input); 



function buttononclick()
{


}

1 个答案:

答案 0 :(得分:0)

如果我正确理解了这一点,那么当您单击按钮时,您希望使用类h1更改div中的文本。如果是这种情况,您可以:

 function buttononclick(){
    document.getElementsByClassName('h1')[0].innerHTML = "Changed";
 }
相关问题