HOW TO REPLACE A WORD IN A STRING USING JQUERY?

Chris S

Total Post:48

Points:336
Posted by  Chris S
 1034  View(s)
Ratings:
Rate this:
I've tried using replaceAll and replaceWith and they don't seem to work

for example, string

"~/Foo.aspx?fn=/image.jpg&p=True"

I want to do is replace p=True with p=False

var previewSource = "~/Foo.aspx?fn/image.jpg&p=True"

var loadedSource = $(previewSource).replaceAll("p=True").replaceWith("p=False");

  1. Pawan Shukla

    Post:29

    Points:203
    Re: How to replace a word in a string using JQuery?

    You can use pure Javscript here:

    var previewSource = '~Foo.aspx?fn/image.jpg&p=True';

    var loadedSource = previewSource.replace("p=True", "p=False");

      Modified On Mar-17-2016 04:14:08 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!