Change default text with Javascrip
2 posters
Page 1 of 1
Change default text with Javascrip
Yes, I know I've asked for a variable change text, but now I need to change the text on just text you can not edit through the templates.
Can I have an example code for this? I previously tried it with this code and there was no success.
Can I have an example code for this? I previously tried it with this code and there was no success.
- Code:
jQuery(function(){var x=document.getElementById('#stats').nextSibling;x.innerHTML=x.innerHTML.replace(/Users browsing this forum:/g,"Users viewing this forum:")});
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
I figured you or LGforum would post the code and correct me. Javascript is hard for me, I just don't understand why to use all them little symbols.
How could I add multiple things to change?
How could I add multiple things to change?
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
RegExp can have spaces in, and you can perform a literal match.
For just changing one word, you don't even need a Regexp, the .replace() will accept just a string as its first parameter.
.replace('browing', 'viewing')
For just changing one word, you don't even need a Regexp, the .replace() will accept just a string as its first parameter.
.replace('browing', 'viewing')
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Change default text with Javascrip
Could I have the code if I wanted to change more than one text? I can't create all kinds of Javascripts with only one word change.
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
If your changing the text in the same element then the .replace function can be chained.
.replace('browing', 'viewing').replace('users','members').replace('forum','section');
But ultimately, it depends what your wanting to change and move around.
.replace('browing', 'viewing').replace('users','members').replace('forum','section');
But ultimately, it depends what your wanting to change and move around.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Change default text with Javascrip
I'm wanting to change a whole new element, I guess you'd call it. Not in the stats.
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
I know that, but I want to know how I can edit two things without having to create a new javascript.
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
Can you post me a code of an example?
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
No, I mean how can I change two things in different element names.
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
Bump again!
!_NICK_!- Active Poster
- Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.
Re: Change default text with Javascrip
Well this is from your first post:
Just do the same for another element. Using a different variable name.
- Code:
var x=document.getElementById('stats');
Just do the same for another element. Using a different variable name.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum