0

In a website, is there any way of changing text attribute of keyword, like product name, in an entire website without using any kind of html tags wrapped around those instances? I may require to define those keywords in server side environment or there may be a server side script in which I may need to define. Or can we use client side Javascript like some jquery plugin?

Silkograph
  • 85
  • 2
  • 12

1 Answers1

0

You can use Javascript on the client side to achieve this.
Drawing from this answer the following is a simple example:

Sample Jsfiddle

JS:

$('*').contents().each(function(){
    if(this.nodeType === 3) {
        $(this).replaceWith(this.wholeText.replace(/target/g, 'replaced'));    
    }
});

HTML:

<h1>target</h1>
<p>Here it is: <span>target</span> and target</p>
Community
  • 1
  • 1
Etheryte
  • 24,589
  • 11
  • 71
  • 116
  • Yes, that solved my problem. I can add span tag with some css class through this replace function. $(this).replaceWith(this.wholeText.replace(/target/g, 'Target')); I was exactly looking for this functionality. Thanks a lot. – Silkograph Jun 10 '14 at 13:39