Possible Duplicate:
How do I change the text of a span element in javascript
Well, I've searched a lot for the answer to this, but still I couldn't find it. What I did find didn't work.
What I'm trying to do is, basically, using JavaScript: At the browser's bar, not via Greasemonkey or something else, edit a span's text .
This' the span that contains the text I want to edit:
<span id="serverTime">5:46:40</span>
The time within is just random, don't pay attention to it, it's what I want to edit using javascript..
I'm a newbie so yeah :\
Use the textContent property to change the text of a span element, e.g. span. textContent = 'Replacement text' . The textContent property will set the text of the span to the provided string, replacing any of the existing content.
Use the textContent property to get the text of a span element, e.g. const text = span. textContent . The textContent property will return the text content of the span and its descendants.
To change the text font in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-family, font-size, font-style, etc. HTML5 do not support the <font> tag, so the CSS style is used to change font.
The <span> tag is an inline container used to mark up a part of a text, or a part of a document. The <span> tag is easily styled by CSS or manipulated with JavaScript using the class or id attribute.
document.getElementById("serverTime").innerHTML = ...;
Replace whatever is in the address bar with this:
javascript:document.getElementById('serverTime').innerHTML='[text here]';
Example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With