Change the value of an existing onclick function
- by Mark Peach
I have a page that is pulling in via an iframe a page of html content from a pre-existing content management system, whose content I can not directly change. I want to use jquery to alter some of the links and button locations dynamically.
For links within the page I was able to change the href attr values of
<a href="/content.asp">more</a>
from content.asp to content2.asp using
$("a[href^='/content.asp']")
.each(function() { this.href = this.href.replace("content.asp", "content2.asp"); });
But the page pulled in also has form buttons that contains javascript onclick functions e.g.
<INPUT type="button" value="Add to basket" onClick="document.location='/shopping-basket.asp?mode=add&id_Product=1076';">
I basically want to use jquery to select any such buttons and change the shopping-basket.asp to shopping-basket2.asp
How can I select these buttons/onclick functions and change the location string?