Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript need help with a little script

u0lf

New Coder
hi, i'm new here, i had this idea to start making a browser extension.
got no problems with the html part but when it came to js i started to struggle, mainly cause i dont know anything about js.
i wanted to make a script that replaces a certain text in the html page opened on the browser with another text while pressing a certain button.
got no problems with the button part since as i said before i know html *decently*, can anybody help me with the js part?
if that can help in any way the browser i'm creating it on is edge (so chrome too ig)
 
Hello u0lf!

Here we change the content of an element with the id 'someId':
JavaScript:
document.getElementById("someId").innerHTML = "Some text";
 
An id is used to uniquely identify an element. Here we define an element with the id 'id1':
HTML:
<p id="id1"></p>
Here we retrieve that element in JS:
JavaScript:
document.getElementById("id1")
Here we change the content of the element:
JavaScript:
document.getElementById("someId").innerHTML = "Some text";
After the code above is executed, the element becomes:
HTML:
<p id="id1">Some text</p>
 

New Threads

Buy us a coffee!

Back
Top Bottom