I have a series of links on a SharePoint page and am trying to modify one of the common URL parameters of them all. The links all look similar to this:
<a href="javascript:" onclick="javascript:RefreshPageTo(event, '/dev/Pages/stPCT.aspx?Paged=TRUE&p_ID=357\u0026PageFirstRow=31\u0026FilterField1=Number&FilterValue1=0000123450&&\u0026View={FC071FA0-12AA-7854-905E-0C4429FFFD52}&thisID=STRINGID');javascript:return false;" id="PagingLink" class="PagingLink">
Next</a>
What I am trying to get to happen is that the link is rewritten to change "thisID=STRINGID" to "thisID=0000123450"... So far I have tried (without success) the following.
$(".PagingLink").each( function(index,element) {
url = $(element).onclick();
console.log(url);
newurl = url.replace(/STRINGID/gi,"0000123450");
$(element).attr('href', newurl);
});
Any and all help would be greatly appreciated.
I'll do it like this:
$(".PagingLink").each( function(index,element) {
url = $(element).attr('onclick');
console.log(url);
newurl = url.replace(/STRINGID/gi,"0000123450");
$(element).attr('href',newurl);
});
Your mistake was in the .onclick, you should get it with attr() because it garantess you to get the correct value.