简体   繁体   中英

how replace url with url using jquery or javascript

I have the below code...and as you can see there is a below url in the code,

http://i1263.photobucket.com/albums/ii624/davgrig04/suitmeasurementchart.jpg

I want to replace this url with another url when the page loads using jquery or java...how should i do that? ...Please explain in easy words...as i have 0 knowledge about java...

 <td width="664" valign="top" style="padding: 0in 5.4pt; border: 1pt solid #78c0d4;"> <p style="text-align: left;"><span color="#006988" face="Courier" style="color: #006988; font-family: Courier;"><a href="http://i1263.photobucket.com/albums/ii624/davgrig04/suitmeasurementchart.jpg"><b>Measurement Chart</b></a></span></p> </td> 

Add id to <a> tag.

<a id="myChart" href="http://i1263.photobucket.com/albums/ii624/davgrig04/suitmeasurementchart.jpg">

Add JavaScript

document.getElementById("#myChart").href = "new_chart_file.jpg";

Add an id to the tag as @Hamza Rashid said.

To make sure the url is changed when the window loads, add this function:

window.onload = function(){
document.getElementById("#myChart").href = "new_chart_file.jpg";
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM