html - jQuery how to replace src url -


I have a page that I'm scrapping, scrap page used relative path for my pictures And when I load my page, the url of my site is being put on the source ARTR. I can find a way to change my URL in order for images and other items with a remote site's URL, which refers to it to display properly on my page.

I have a script used for scraps:

  & lt; Script src = "path_to_jquery.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ Document.ready (function () {$ ("#weather") .load ("http://weather.com" Table: nth-child (3) ", function () {$ (this) .find (" IMG "). Each (function () {$ (this) .attr (" src ") .replace ('http://my_site.com', 'http://weather.com))}})}}; }};  

I have added the last line, hoping to clean up the problem, but it is not working yet. The path needs to be maintained, when I change my URL with the target URL, then the rest of the SRROC ARR needs to be there For example, when the page is opened, I see the table and all the text properly, but the images fail to load because I do not live on the server, so I have to update the source ART from this: < / P>

  http://my_site.com/images/sunny.jpg  

To do this:

  http: //weather.com/images/sunny.jpg  

Any insights will be appreciated.

replace call copy With the installation of a new string. Your code creates a new string which is called weather.com instead of my_site.com , but does nothing with string.

You need to write the following:

  $ (this) .attr ("src", function (index, old) {old old location ('http : //my_site.com ',' http: //weather.com ");});  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -