The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Change default text with Javascrip

View previous topic View next topic Go down

Change default text with Javascrip

Post by !_NICK_! on May 4th 2012, 2:33 am

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.

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

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 4th 2012, 4:03 am

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?

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by LGforum on May 4th 2012, 2:42 pm

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')

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 4th 2012, 10:33 pm

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. Wink

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by LGforum on May 4th 2012, 10:41 pm

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.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 4th 2012, 11:17 pm

I'm wanting to change a whole new element, I guess you'd call it. Not in the stats.

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 5th 2012, 12:44 am

I know that, but I want to know how I can edit two things without having to create a new javascript.

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 5th 2012, 2:20 am

Can you post me a code of an example?

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 6th 2012, 6:32 pm

Bump!

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 9th 2012, 1:55 am

No, I mean how can I change two things in different element names.

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 10th 2012, 4:22 am

Bump!

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by !_NICK_! on May 12th 2012, 12:52 am

Bump again!

!_NICK_!
Active Poster

Male Posts : 1505
Reputation : 69
Language : English, HTML, and CSS
Location : In the middle of no return.

Back to top Go down

Re: Change default text with Javascrip

Post by LGforum on May 12th 2012, 3:45 am

Well this is from your first post:
Code:
var x=document.getElementById('stats');
That gets one element ready to manipulate.

Just do the same for another element. Using a different variable name.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum