tags:

views:

77

answers:

1
+4  Q: 

Search and replace

Hi. I'm working on a new project and i want to do something similar (somehow) to intellitext ads (without popup though). In fact, i want to add links on certain words. The problem is that i don't know how to handle this.

I mean, ok, i get document.innerHTML then what? I can find any word, but some may be inside of tags. I don't want to replace words from textarea or text inside of a link. Same for input, select, and so on.

Also, the way i've managed things, i replace even the html tags (if the word is select for example, the script will replace <select> tag. And i really don't want this :P

So, any idea? Where to start ? What to do? Anything?

I wish a solution that works without any library, or, if is mandatory, to work with jquery (this is what i know).

I think that some regexp may help. The problem is... I never understand them :s

Any help will be appreciated. Thanks a lot!

+1  A: 

jQuery does this already!

Just use .text() to get all the text underneath. Documentation and examples are here.

Jason Cohen
hmmm... i will give a shot. Thanks!
Ionut Staicu