讨论 » 创建请求

How to write user script to replace inner html

§
发布于:2022-02-01

My div id is ," my_age" and inner html property is "45"

So I want to change inner html as '56'

What are the java script code to write for tamper monkey....pls help me

§
发布于:2022-02-01

I think property can mean a lot of things, so you should be more specific.

document.querySelector("#my_age , .my_age").innerHTML = '56';

You might actually be talking about innerText instead of innerHTML.

§
发布于:2022-03-20

To briefly explain the differences, here's some code:

var div = document.createElement("div"); // <div></div>

div.innerText = "<h1>Hello</h1>"; // <div>"<h1>Hello</h1>"</div>
div.innerHTML = "<h1>Hello</h1>"; // <div><h1>"Hello"</h1></div>

And here's the result of the code:

<h1>Hello</h1>

Hello

§
发布于:2022-03-23

I think the above has already answered your question. But try the method that is described on the casinoshunter. It seems to me that he will be more working in the end.

Deleted user 821489
§
发布于:2022-08-08

var html = document.getElementsByTagName('html')[0];
// do something in html.TAG_NAME
html.innerHTML = html.innerHTML;

发布留言

登录(不可用)以发布留言。

长期地址
遇到问题?请前往 GitHub 提 Issues。